假设我有以下设置:
ssh ssh A ------> B ------> C ^ ^ using A's using B's key key
我正在尝试在主机A
.ssh/config
中configuration它,如下所示:
Host C HostName C.com IdentityFile path_to_key_1 ProxyCommand ssh -i path_to_key_2 B -W %h:%p
哪个标识文件和path进入path_to_key_1
和path_to_key_2
?
例如, path_to_key_1
引用A
的path, path_to_key_1
引用B
的path? 或者他们都被认为是A
path?
ProxyCommand
是从'A'执行的,这个连接到B只创build一个'C'的隧道 ,然后用'A'连接到'C'。 B上没有打开的shell,或者从B加载的任何SSH密钥。
如果您只需要一个身份validation密钥(只能在“B”上validation为“C”),您将无法使用“ProxyCommand”。
主机A
上的.ssh/config
应该如下所示:
Host B HostName B.com IdentityFile path_to_key_2 Host C HostName C.com IdentityFile path_to_key_1 ProxyCommand ssh B -W %h:%p
两个path_to_key
文件都必须存在于A
。
我在生产中使用类似的configuration来访问nagios nrpe服务器。
编辑:更改主机C
configuration,从ProxyCommand ssh -i path_to_key_2 B -W %h:%p
删除-i
部分ProxyCommand ssh -i path_to_key_2 B -W %h:%p
因为它是多余的