Repeated password prompt with Maven deploy-file to scp repository
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 {execut开发者_StackOverflow中文版ion: 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:
- I'm prompted for a password even though it is is specified in the settings.xml
- The password is echoed back on the console
- 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.
I found the following on the maven-users list:
the sshd on the server used PasswordAuthentication no
. After
switching to yes
my maven config works fine.
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.
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 username@example.com:/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.
We have since installed Nexus as an repository manager and are using the web interface to upload third party jars.
I don't have an exact solution, but at least the following works:
Create a server entry in the file ~/.m2/settings.xml:
<server>
<id>example-dist</id>
<username>myusername</username>
<password>ignored</password>
</server>
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).
This bug seems related.
http://jira.codehaus.org/browse/WAGON-323
Im am getting the message "Keyboard interactive required, supplied password is ignored" - even with wagon-ssh-2.4.
Tried to set <interactiveMode>false</interactiveMode>
but then auth fails right away.
As per @Gerbrand's response, you can skip providing user credentials with ssh keys. The steps are the following:
If you do not have one yet, generate a private/public key pair with
ssh-keygen
. Let's say you store the private key in/home/user/.ssh/id_rsa
Copy the public key to the destination server with
ssh-copy-id -i /home/user/.ssh/id_rsa USER@serverhostname
Change your
settings.xml
to use your keys instead of password<server> <id>serverhostname</id> <username>USER</username> <privateKey>${user.home}/.ssh/id_rsa</privateKey> <!-- Note there is no password tag specified --> </server>
Next time you need to login to the server via Maven, no password will be requested.
精彩评论