Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven won't use public key to deploy

I'm using SSH to deploy my Java artifacts to a server. I have the keys set up so that I can interactively SSH to the server without requiring a password, but when I try to run the "mvn deploy" or "mvn release:perform" commands, it hangs (at what I assume is the password prompt).

My ~/.m2/settings.xml file contains the username for the server (because it is different than my local username) and references the id of the server that requires the different user.

like image 663
magneticMonster Avatar asked May 09 '10 01:05

magneticMonster


2 Answers

Are you sure your settings.xml provides everything required? Did you declare your privateKey (and the passphrase if necessary)? Something like this:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <servers>
    <server>
      <id>server001</id>
      <username>my_login</username>
      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase> <!-- if required -->
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  ...
</settings>
like image 174
Pascal Thivent Avatar answered Oct 16 '22 08:10

Pascal Thivent


In your distributionManagement section, try using "scpexe://" in your url instead of "scp://".

This calls the standard scp program (assuming it is on your path), instead of using the Java implementation of scp that is built into Maven. Standard scp uses ssh-agent (which, in Ubuntu, starts automatically when you log in through GDM) for public-key auth.

like image 38
stacktracer Avatar answered Oct 16 '22 10:10

stacktracer