跳过主机并使用单个sshconfiguration文件时不同的身份文件

假设我有以下设置:

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_1path_to_key_2

例如, path_to_key_1引用A的path, path_to_key_1引用B的path? 或者他们都被认为是Apath?

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服务器。

编辑:更改主机Cconfiguration,从ProxyCommand ssh -i path_to_key_2 B -W %h:%p删除-i部分ProxyCommand ssh -i path_to_key_2 B -W %h:%p因为它是多余的