更新:下面描述的整个事情适用于远程计算机上的非root帐户。
也就是说,这个工作:
anderson@client -> nonroot@remote -> anderson's-ssh[email protected]
但是这不起作用:
anderson@client -> root@remote -> anderson'[email protected]
所以问题是,当中间的机器是root时,如何让ssh代理转发工作?
本地计算机(OSX)在〜/ .ssh / config文件中打开了转发:
Host remotehost ForwardAgent yes
本地机器不会覆盖/ etc / ssh / ssh_config中的此设置。
Host * # ForwardAgent no
本地机器正在运行ssh-agent:
anderson$ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-L0iFZ891Gv/agent.75083; export SSH_AUTH_SOCK; SSH_AGENT_PID=75084; export SSH_AGENT_PID; echo Agent pid 75084;
已经对密钥执行了ssh-add:
anderson$ ssh-add -K ~/.ssh/id_rsa Passphrase updated in keychain: /Users/anderson/.ssh/id_rsa Identity added: /Users/anderson/.ssh/id_rsa (/Users/anderson/.ssh/id_rsa)
$ SSH_AUTH_SOCK在那里:
anderson$ echo $SSH_AUTH_SOCK /tmp/launch-pg2gVc/Listeners
ssh密钥已经上传到GitHub并正在工作:
anderson$ ssh -T [email protected] Hi [elided]! You've successfully authenticated, but GitHub does not provide shell access.
远程机器(Ubuntu 12.04LTS)具有本地机器的公共ssh密钥,它的工作原理是:
anderson$ ssh root@remotehost [root@host1~]#
远程机器已configurationAllowAgentForwarding:
[root@host1~]# head /etc/ssh/sshd_config # Package generated configuration file # See the sshd_config(5) manpage for details AllowAgentForwarding yes
这里是梨形的地方:SSH_AUTH_SOCK无处可寻:
[root@host1~]# echo $SSH_AUTH_SOCK **crickets**
当然,密钥转发也是无处可寻的:
[root@host1~]# ssh -T [email protected] Permission denied (publickey).
即使像这样强迫它不起作用:
anderson$ ssh -A root@remotehost
debugging输出:
anderson$ ssh -vvv -A root@remotehost OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /Users/anderson/.ssh/config debug1: Applying options for remotehost debug1: Applying options for * debug1: Reading configuration data /etc/ssh_config debug1: Applying options for * debug1: auto-mux: Trying existing master debug2: fd 3 setting O_NONBLOCK debug2: mux_client_hello_exchange: master version 4 debug3: mux_client_request_forwards: requesting forwardings: 0 local, 0 remote debug3: mux_client_request_session: entering debug3: mux_client_request_alive: entering debug3: mux_client_request_alive: done pid = 45287 debug3: mux_client_request_session: session request sent debug1: mux_client_request_session: master session id: 3
所以我错过了什么? 在我看来,我已经涵盖了所有debugging的基础。 任何想法,我还可以检查什么?
我有类似的情况,原因是我使用的包装是设置ControlPath选项,SSH也卡在debug1: mux_client_request_session: master session id: 3 。 删除ControlPath中指定的目录已解决该问题。