为什么ssh-agent转发不能用于特定用户?

为了让两个用户有效地使用SSH代理转发,我遇到了很多困难。

两者都可以毫无问题地login到远程服务器,而且看起来他们的代理正在正确转发(在服务器上,“echo $ SSH_AGENT_SOCK”返回对存储在/tmp/ssh-blahblahbla/agent.blahblah上的套接字的引用) ,但是用户在通过sshlogin到其他服务器之后,都不能通过ssh访问其他服务器,也不能从通过ssh托pipe和访问的git repo中获取信息。

所有这些东西都适用于所有其他用户。 我注意到唯一的区别是,由于一些莫名其妙的原因,在这些问题用户ssh到第一台服务器并尝试连接到第二个后,ssh verbose输出显示以下内容:

debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/ubuntu/.ssh/identity ((nil)) debug2: key: /home/ubuntu/.ssh/id_rsa ((nil)) debug2: key: /home/ubuntu/.ssh/id_dsa (0x7ff42705ab40) debug3: Wrote 64 bytes for a total of 1127 debug1: Authentications that can continue: publickey debug3: start over, passed a different list publickey debug3: preferred gssapi-keyex,gssapi-with-mic,gssapi,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/ubuntu/.ssh/identity debug3: no such identity: /home/ubuntu/.ssh/identity debug1: Trying private key: /home/ubuntu/.ssh/id_rsa debug3: no such identity: /home/ubuntu/.ssh/id_rsa debug1: Offering public key: /home/ubuntu/.ssh/id_dsa 

对于成功的用户,前几行通过$ SSH_AUTH_SOCK引用/ tmp中的套接字。 我很困惑,从哪里开始寻找帮助?

此外,作为参考,它不一定是关键的具体。 对于一个用户,我尝试生成两个新的密钥(不同的types之一,不同的encryption之一),没有一个工作。

思考?

我发现,即使代理密钥被转发,两个用户都没有身份。

检查本地机器使用:

 ssh-add -L 

如果您看到:代理没有身份。

您可能还需要键入:

 ssh-add 

这解决了我们的问题。 我希望它能帮助别人。

在一种情况下,用户具有本地身份,但不是他正在使用的密钥,而是在不同环境中使用的备用密钥。 既然他能在这样的环境中如预期的那样进行代理,那就给了我们这个问题在服务器端的印象。 为了添加一个特定的身份,我们使用

 ssh-add ~/.ssh/his-alternate-keyfile