本文介绍了Maven Wagon插件可以将私钥用于scp吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将Maven Wagon插件配置为对ssh/scp使用私钥吗?我尝试过的每件事仍然使专家想找密码时都要求我输入密码.

Can Maven Wagon plugin be configured to use a private key for ssh/scp? Everything I've tried still leaves maven to ask me for a password when it gets to the point of scp-ing.

推荐答案

您应该能够在服务器元素:

<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>
      <password>my_password</password>
      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  ...
</settings>

  • id :这是 服务器(不是以该用户身份登录的用户) 与的id元素匹配 Maven尝试存储库/镜像 连接到.
  • 用户名密码:这些元素成对出现,表示登录名和密码 需要对此进行身份验证 服务器.
  • 私人密钥密码:类似于前两个元素,该对指定了一条路径 到私钥(默认为 ${user.home}/.ssh/id_dsa)和一个 密码(如果需要).这 密码和密码元素可能 在将来被外部化,但是对于 现在必须在 settings.xml文件.
  • filePermissions directoryPermissions :当存储库文件或目录为 在部署时创建的,这些是 使用权限.法律价值 每个都是三位数 对应于* nix文件 权限,即. 664或775.
    • id: This is the ID of the server (not of the user to login as) that matches the id element of the repository/mirror that Maven tries to connect to.
    • username, password: These elements appear as a pair denoting the login and password required to authenticate to this server.
    • privateKey, passphrase: Like the previous two elements, this pair specifies a path to a private key (default is ${user.home}/.ssh/id_dsa) and a passphrase, if required. The passphrase and password elements may be externalized in the future, but for now they must be set plain-text in the settings.xml file.
    • filePermissions, directoryPermissions: When a repository file or directory is created on deployment, these are the permissions to use. The legal values of each is a three digit number corresponding to *nix file permissions, ie. 664, or 775.
    • 注意:如果您使用私钥来 登录到服务器,请确保您 省略<password>元素. 否则,密钥将被忽略.

      Note: If you use a private key to login to the server, make sure you omit the <password> element. Otherwise, the key will be ignored.

      密码加密

      一项新功能-服务器密码和 密码加密已添加 到2.1.x和3.0中继.查看具体信息 在此页面上.

      A new feature - server password and passphrase encryption has been added to 2.1.x and 3.0 trunks. See details on this page.

      特别注意"note":如果使用私钥登录服务器,请确保省略<password>元素.否则,密钥将被忽略.因此最终配置将接近:

      Pay a special attention to the "note": If you use a private key to login to the server, make sure you omit the <password> element. Otherwise, the key will be ignored. So the final configuration will be close to:

      <settings>
        ...
        <servers>
          <server>
            <id>ssh-repository</id>
            <username>your username in the remote system</username>
            <privateKey>/path/to/your/private/key</privateKey>
            <passphrase>sUp3rStr0ngP4s5wOrD</passphrase><!-- if required -->
            <configuration>
              ...
            </configuration>
          </server>
        </servers>
        ...
      </settings>
      

      这篇关于Maven Wagon插件可以将私钥用于scp吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 05:21
查看更多