Amazon web services 尝试从从属节点ssh到GIT时权限被拒绝(公钥)

Amazon web services 尝试从从属节点ssh到GIT时权限被拒绝(公钥),amazon-web-services,jenkins,ssh,amazon-ec2,Amazon Web Services,Jenkins,Ssh,Amazon Ec2,所以我正在尝试为Jenkins设置一个ssh密钥。出于某种原因,我得到: Permission denied (publickey). 完整堆栈跟踪是: [jenkins@ip-xx-xx-xx-xxx .ssh]$ ls authorized_keys id_rsa id_rsa.pub known_hosts [jenkins@ip-xx-xx-x-xxx .ssh]$ ssh -vT ddennis@git.xxxxxx.com OpenSSH_6.6.1, OpenSSL 1.

所以我正在尝试为Jenkins设置一个ssh密钥。出于某种原因,我得到:

Permission denied (publickey). 
完整堆栈跟踪是:

[jenkins@ip-xx-xx-xx-xxx .ssh]$ ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[jenkins@ip-xx-xx-x-xxx .ssh]$ ssh -vT ddennis@git.xxxxxx.com
OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to git.viasat.com [xx.xx.xxx.xx] port 22.
debug1: Connection established.
debug1: identity file /home/jenkins/.ssh/id_rsa type 1
debug1: identity file /home/jenkins/.ssh/id_rsa-cert type -1
debug1: identity file /home/jenkins/.ssh/id_dsa type -1
debug1: identity file /home/jenkins/.ssh/id_dsa-cert type -1
debug1: identity file /home/jenkins/.ssh/id_ecdsa type -1
debug1: identity file /home/jenkins/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/jenkins/.ssh/id_ed25519 type -1
debug1: identity file /home/jenkins/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: kex: ecdh-sha2-nistp256 need=20 dh_need=20
debug1: kex: ecdh-sha2-nistp256 need=20 dh_need=20
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA aa:f3:39:39:58:2b:61:ad:e8:d3:7a:f2:d2:e9:dd:7a
debug1: Host 'git.xxxxxx.com' is known and matches the ECDSA host key.
debug1: Found key in /home/jenkins/.ssh/known_hosts:3
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jenkins/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/jenkins/.ssh/id_dsa
debug1: Trying private key: /home/jenkins/.ssh/id_ecdsa
debug1: Trying private key: /home/jenkins/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
我也在git中将ssh密钥设置为我的用户。
我跑:

在我的从属节点上,它与加载到git中的节点匹配。
我还将该密钥复制到我的授权密钥文件中。

已经玩了一段时间了,任何建议都是有用的

首先尝试在不使用密码短语的情况下生成ssh密钥:这样您就不必担心ssh添加

ssh-keygen -t rsa -C "key for xxx access" -q -P ""
(不需要油灰)
(不需要)

一定要保证安全

确保已在服务器中正确复制公钥:

~/ddennis/.ssh/authorized_keys 
(作为一条连续线)



之后,如果
ssh-Tv
确实有效,但Jenkins本身不起作用,这通常是因为Jenkins没有使用相同的帐户运行,也没有寻找相同的ssh密钥集。

因此,这似乎可以解决问题。我一定是被允许了。但由于某些原因,在Jenkins上,我仍然得到返回的状态代码128:stdout:stderr:Permission denied(publickey)。致命:无法从远程存储库读取。但它正在成功地执行代码和构建。如果你对此有任何见解的话。对我来说似乎很奇怪。@DavidDennis如果ssh-Tv确实起作用,但是Jenkins本身不起作用,这通常是因为Jenkins没有使用相同的帐户运行,也没有寻找相同的ssh密钥集。这就是我一直在寻找的答案。谢谢你。@DavidDennis太好了!我在回答中加入了这一评论,以提高其可视性。
~/ddennis/.ssh/authorized_keys