使用 Maven 将文件部署到 scp 存储库时重复提示密码

发布于 2024-09-17 09:14:07 字数 2579 浏览 11 评论 0原文

我正在尝试将工件部署到可通过 scp 访问的远程存储库,但遇到重复密码提示的问题。我的 settings.xml 包含此片段:

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

命令行交互如下所示:

$ 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] ------------------------------------------------------------------------

这里有几个问题:

  1. 即使在 settings.xml 中指定了密码,也会提示我输入密码 密码
  2. 会在控制台上回显
  3. 确实如此不记得密码了,反而问了我四次。

我如何配置maven,以便它使用settings.xml中的密码或询问我一次而不将我的密码回显到屏幕上?

编辑: 这是在 Ubuntu Linux 上,一位同事刚刚在 Windows XP 上重现了同样的问题。由于在 Windows 上无法将存储库安装到本地路径,因此我仍在寻找解决方案。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

过气美图社 2024-09-24 09:14:07

我在 maven-users 列表中发现以下内容:

服务器上的 sshd 使用 PasswordAuthentication no。后
切换到 yes 我的 Maven 配置工作正常。

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.

八巷 2024-09-24 09:14:07

您是否在您的中设置了 repositoryId pom 使用 settings.xml 中的正确服务器条目,因为看起来您没有设置它,所以它使用 id:remote-repository。或者您是否相应地更改了settings.xml。

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.

耳钉梦 2024-09-24 09:14:07

作为解决方法,我目前使用 sshfs 挂载远程存储库,然后在 maven 命令中使用文件 url:

$ 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/

在这种情况下,不需要在 settings.xml 中配置服务器,不需要在命令行上指定repositoryId,并且我可以在文件 url 上使用 shell 自动完成功能。

如果有人可以重现该问题或使用 Maven 标准提出解决方案,我仍然会感兴趣。

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.

忆伤 2024-09-24 09:14:07

此后,我们安装了 Nexus 作为存储库管理器,并使用 Web 界面上传第三方 jar。

We have since installed Nexus as an repository manager and are using the web interface to upload third party jars.

心房敞 2024-09-24 09:14:07

我没有确切的解决方案,但至少可以执行以下操作:

在文件 ~/.m2/settings.xml 中创建服务器条目:

<server>
  <id>example-dist</id>
  <username>myusername</username>
  <password>ignored</password>
</server>

执行部署或部署:部署文件如下:

mvn deploy -DrepositoryId=example-dist

系统会要求您提供提供的用户名的密码 - settings.xml 中的密码将被忽略。

如果您不想每次都提供密码,可以通过使用 ssh-keygen 生成 ssh 密钥来实现。您必须将生成的公钥存储在分发服务器上的authorized_keys 文件中(为了获得更好的解释,请参阅网络上的一些教程或手册页)。

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).

∞觅青森が 2024-09-24 09:14:07

这个错误似乎相关。
http://jira.codehaus.org/browse/WAGON-323
我收到消息“需要键盘交互,提供的密码被忽略” - 即使使用 wagon-ssh-2.4 也是如此。
尝试设置 false 但身份验证立即失败。

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.

贱人配狗天长地久 2024-09-24 09:14:07

根据 @Gerbrand 的回复,您可以跳过使用 ssh 密钥提供用户凭据。步骤如下:

  1. 如果您还没有密钥,请使用 ssh-keygen 生成私钥/公钥对。假设您将私钥存储在 /home/user/.ssh/id_rsa

    中,

  2. 使用 ssh-copy-id -i /home/user 将公钥复制到目标服务器/.ssh/id_rsa USER@serverhostname

  3. 更改您的settings.xml以使用密钥而不是密码

    <预><代码><服务器>;
    服务器主机名
    <用户名>USER${user.home}/.ssh/id_rsa

下次您需要通过 Maven 登录服务器时,将不需要密码。

As per @Gerbrand's response, you can skip providing user credentials with ssh keys. The steps are the following:

  1. 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

  2. Copy the public key to the destination server with ssh-copy-id -i /home/user/.ssh/id_rsa USER@serverhostname

  3. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文