views:

144

answers:

3

I'm trying to deploy an artifact to a remote repository accessible via scp and having a problem with repeated password prompts. My settings.xml contains this fragment:

<servers>
    <server>
        <id>example.com</id>
        <username>myusername</username>
        <password>mypassword</password>
        <filePermissions>664</filePermissions>
        <directoryPermissions>775</directoryPermissions>
        <configuration>
        </configuration>
    </server>
</servers>

The command line interaction looks like this:

$ mvn deploy:deploy-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=11.2.0.1.0 -DrepositoryId=example.com -Durl=scp://example.com/maven2/
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [deploy:deploy-file {execution: default-cli}]
Keyboard interactive required, supplied password is ignored
Password: : mypassword
Uploading: scp://example.com/maven2//com/oracle/ojdbc6/11.2.0.1.0/ojdbc6-11.2.0.1.0.jar
2061K uploaded  (ojdbc6-11.2.0.1.0.jar)
[INFO] Retrieving previous metadata from example.com
Keyboard interactive required, supplied password is ignored
Password: : mypassword
[INFO] repository metadata for: 'artifact com.oracle:ojdbc6' could not be found on repository: example.com, so will be created
[INFO] Uploading repository metadata for: 'artifact com.oracle:ojdbc6'
Keyboard interactive required, supplied password is ignored
Password: : mypassword
[INFO] Uploading project information for ojdbc6 11.2.0.1.0
Keyboard interactive required, supplied password is ignored
Password: : mypassword
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 seconds
[INFO] Finished at: Thu Sep 02 13:03:33 CEST 2010
[INFO] Final Memory: 5M/90M
[INFO] ------------------------------------------------------------------------

There are several problems here:

  1. I'm prompted for a password even though it is is specified in the settings.xml
  2. The password is echoed back on the console
  3. It does not remember the password and instead asks me 4 times.

How can I configure maven so it either uses a password from settings.xml or asks me once without echoing my password to the screen?

Edit: This was on Ubuntu linux, a collegue just reproduced the same problem on Windows XP. As mounting the repository to a local path is not an option on Windows, I'm still looking for a solution.

A: 

Have you set either the repositoryId in your pom to use the correct server entry from the settings.xml, cause it looks like you don't set that so it uses the id: remote-repository. or did you changed the settings.xml accordingly.

khmarbaise
I don't have a pom since this is an external artifact which I downloaded. The repositoryId is specified on the command line via `-DrepositoryId=example.com`. The server settings seem to be used by maven since it does not ask me for my username, which is only set in settings.xml.
Jörn Horstmann
A: 

As a workaround, I'm currently mounting the remote repository using sshfs and then using a file url in the maven command:

$ sudo adduser jh fuse
$ sudo mkdir -p /mnt/example.com/maven2
$ sudo chown -R jh:jh /mnt/example.com
$ sshfs [email protected]:/maven2 /mnt/example.com/maven2
$ mvn deploy:deploy-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dpackaging=jar -Dversion=11.2.0.1.0 -Durl=file:///mnt/example.com/maven2/repository/

Configuring the server in settings.xml is not needed in this case, the repositoryId need not be specified on the command line and I can use shell autocompletion on the file url.

I would still be interested if anyone can reproduce the problem or suggest a solution using maven standards.

Jörn Horstmann
A: 

I have a similar problem, I don't have an exact solution, but at least the following works:

Create a server entry in the file ~/.m2/settings.xml: example-dist myusername ignored

Perform the deploy or deploy:deploy-file as follows: mvn deploy -DrepositoryId=example-dist

You'll be asked for the password for the supplied username - the password in the settings.xml is ignored. If you don't want to supply passwords each time, you can do so by generated a ssh key using ssh-keygen. The generated public key you'll have to store in the authorized_keys files at the distribution server (for a better explanation, see several tutorials on the web or the man page).

Gerbrand