使用-F时,ssh无法从configuration中parsing第二个主机

为了访问特定的机器,我需要通过代理,然后通过一个jumphost,在我在所需的位置之前。

为此,我使用这样的configuration文件:

### jumphost Host jmp HostName xxx.xxx.xxx.xxx:port User user ProxyCommand corkscrew proxy.name.com port %h %p ### box Host box HostName xxx.xxx.xxx.xxx User user ProxyCommand ssh mgmtbox netcat -w 120 %h %p 

只要configuration文件在其设置的位置,这工作得很好。 但是,如果我想用-F标志(“ ssh -F configfile box ”)指定这个configuration文件,我得到以下错误:

 ssh: Could not resolve hostname jmp: Name or service not known 

该问题仅在第二台主机上启动。 如果我使用“ ssh -F configfile jmp ”命令工作正常。

我有点在这里输了,因为configuration文件工作得很好,直到它通过-F标志使用。 有任何想法吗?

只要configuration文件在其设置的位置,这工作得很好。 但是,如果我想用-F标志(“ssh -F configfile box”)指定这个configuration文件,我得到以下错误:

问题是,在运行代理命令时,您不指定configuration位置。 这是完全不相关的ssh实例,因此它不知道主机名。

运用

 ProxyCommand ssh -F configfile mgmtbox netcat -w 120 %h %p 

将使它为你工作。 在另一个答案中指出的另一件事情也适用。

我认为这是问题

HostName xxx.xxx.xxx.xxx:port

我认为应该是

 HostName xxx.xxx.xxx.xxx Port port 

ssh config HostName参数需要一个主机名,而不是主机名:端口