SSH ForwardAgent 多跳

liq*_*ity 15 linux ssh ssh-keys ssh-agent

在过去的 2 个小时里,我一直在寻找解决以下问题的方法,但没有成功。

发展:

我正在使用公钥身份验证连接到我的服务器。我使用 ssh-agent 转发,以便不必管理公钥/私钥。

假设我有服务器A, B and C

如果我从LOCAL ---> A ---> B.

如果我这样做,它也能很好地工作LOCAL ---> A ---> C

现在,如果我尝试LOCAL ---> A ---> B ---> C,SSH 无法从B to C.

值得注意的是:我作为流动性连接到服务器 A,而我作为 root 连接到服务器 B。作为流动性连接到服务器 B 解决了这个问题,但这对我来说不是一个选择。

根据用户的建议,我ssh -A每次都使用以确保启用代理转发。

我发现了一个类似的问题,这里没有答案:Is it possible to chain ssh-agent forwarding through multiple hops?

根据这里的@Zoredache:https ://serverfault.com/a/561576/45671我只需要在每个中间系统上调整我的客户端配置。我相信我做到了。

Zor*_*che 13

要通过多个跃点进行代理转发,您只需调整每个中间系统上的客户端配置,以便代理转发。

这可能就像确保您/etc/ssh/ssh_config已配置好一样简单。但是如果您有每个客户端的配置,~/.ssh/config您可能还需要调整这些设置。

Host *
    ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

您可以查看代理转发是否发生或是否有错误,如果您只是添加该-v选项。

$ ssh -v issc@server1
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/zoredache/.ssh/config
...
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
Linux server1 3.11-0.bpo.2-amd64 #1 SMP Debian 3.11.8-1~bpo70+1 (2013-11-21) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Dec 15 20:39:44 2013 from 10.2.4.243
issc@server1:~$
Run Code Online (Sandbox Code Playgroud)

还要验证您有一个有效的环境变量集。

issc@server1:~$ export | grep SSH_AUTH
declare -x SSH_AUTH_SOCK="/tmp/ssh-7VejOmKtNv/agent.57943"
Run Code Online (Sandbox Code Playgroud)

  • 值得一提的是 ssh 的 -A 标志作为 ssh_config 或 ~.ssh/config 选项的快速而肮脏的替代品。-A [e] 启用身份验证代理连接的转发。 (5认同)