我成功地能够使用SSH连接到远程计算机,但是当我从Jenkins启动代理时,它会抛出以下错误:
ERROR: Server rejected the 1 private key(s) for user1 (credentialId:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/method:publickey) [01/19/17 05:35:15] [SSH] Authentication failed. hudson.AbortException: Authentication failed. at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1219) at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:714) at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:709) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) [01/19/17 05:35:15] Launch failed - cleaning up connection [01/19/17 05:35:15] [SSH] Connection closed.
我可以使用建立从主机到节点机器的SSH连接user1
,但是当我尝试使用user1
jenkins 启动代理时,它拒绝私钥.有没有解决方案可以解决这个问题?
我按照以下步骤解决了这个问题:
从目标从节点的控制台
切换到"root"用户.
sudo su
在家中添加jenkins用户“/var/lib/jenkins”
.{注意:我保留我的主目录/var/lib/jenkins
}:
useradd -d /var/lib/jenkins jenkins
来自詹金斯大师
从主服务器上的Jenkins用户复制id_rsa.pub密钥.
cat /var/lib/jenkins/.ssh/id_rsa.pub
从目标从节点的控制台
为Jenkins用户创建authorized_keys文件.
mkdir /var/lib/jenkins/.ssh
vi /var/lib/jenkins/.ssh/authorized_keys
将Jenkins master中的密钥粘贴到文件vim中.用":wq!"保存.