问题描述
我已经在Jenkins中安装了通过SSH发布"插件,并希望在每次构建后将少量文件传输到SSH服务器.
I Have installed 'Publish Over SSH' plugin in Jenkins and would like to transfer few files to SSH Server after each Build .
我已使用puttygen
和密码生成了私钥,并在SSH服务器的'authorization_keys'中提供了OpenSSH公钥.
I have generated the private key using puttygen
with passphrase and have given the OpenSSH Public Key in 'authorization_keys' in SSH Server.
使用生成的私钥和密码,我可以通过PuTTY登录SSH服务器.
Using the generated private key and passphrase , I'm able to login to the SSH Server through PuTTY.
但是在Jenkins中,我无法添加SSH密钥.出现以下错误.
But in Jenkins I'm not able to add the SSH Key. Getting the below Error.
推荐答案
大多数工具(包括Jenkins)都支持OpenSSH格式(使用ssh-keygen
生成)而不是PuTTY格式(使用PuTTYgen生成)的密钥.使用ssh-keygen
生成新密钥,或将PPK转换为OpenSSH格式.
Most of the tools (including Jenkins) support keys in OpenSSH format (generated using ssh-keygen
), not in the PuTTY format (generated using PuTTYgen). Generate a new key using ssh-keygen
or convert the PPK to OpenSSH format.
我在SO文档中写了以下信息.
I wrote the following information in the SO Documentation.
您可能会从您的对等私钥收到PPK格式,这似乎在OpenSSH中不起作用(命令行ssh
).由于 OpenSSH错误,客户端将要求输入密码.. >
You might receive from your peer private key in PPK format, which seems it does not work in OpenSSH (command-line ssh
). The client will be asking for the passphrase, because of OpenSSH bug.
$ ssh -i mykey.ppk example.com
Enter passphrase for mykey.ppk:
您需要使用PuTTYgen(命令行版本)将密钥转换为OpenSSH格式:
You need to convert the key to OpenSSH format using PuTTYgen (command-line version):
puttygen mykey.ppk -o mykey.key -O private-openssh
或在GUI版本中:
- 打开PuttyGen
- 点击加载
- 加载您的私钥
- 转到转化-> 导出OpenSSH 并导出您的私钥
- 将您的私钥复制到
~/.ssh/id_rsa
- Open PuttyGen
- Click Load
- Load your private key
- Go to Conversions->Export OpenSSH and export your private key
- Copy your private key to
~/.ssh/id_rsa
来源: SO答案,
这篇关于无法在Jenkins配置中添加SSH密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!