SSH 配置文件在全球范围内有效,但不能作为命令行参数
SSH config file works globally but not as command line parameter
我写了一个指定典型跳转服务器设置的 ssh 配置文件:
Host host1
HostName 11.11.11.11
User useroo
IdentityFile some/key/file
Host host2
HostName 192.11.11.10
User useroo
IdentityFile some/other/key
ProxyCommand ssh -W %h:%p host1
当我将其保存为~/.ssh/config
时,我可以成功连接到ssh host2
。但是,如果我将配置保存在其他地方作为 xy_conf
,调用 ssh -F xy_conf host2
会导致错误提示
ssh: Could not resolve hostname host1: Name or service not known
ssh_exchange_identification: Connection closed by remote host
这是预期的行为吗?我还能如何临时设置此配置?我不想将其设置为 ~/.ssh/config
.
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8,OpenSSL 1.0.1f 2014 年 1 月 6 日
对 ssh_config
使用不同的位置只会影响 ssh
的第一次调用,但不会影响第二次调用(也来自 ProxyCommand). You need to pass the same argument to the second
ssh`:
ProxyCommand ssh -F xy_conf -W %h:%p host1
我写了一个指定典型跳转服务器设置的 ssh 配置文件:
Host host1
HostName 11.11.11.11
User useroo
IdentityFile some/key/file
Host host2
HostName 192.11.11.10
User useroo
IdentityFile some/other/key
ProxyCommand ssh -W %h:%p host1
当我将其保存为~/.ssh/config
时,我可以成功连接到ssh host2
。但是,如果我将配置保存在其他地方作为 xy_conf
,调用 ssh -F xy_conf host2
会导致错误提示
ssh: Could not resolve hostname host1: Name or service not known
ssh_exchange_identification: Connection closed by remote host
这是预期的行为吗?我还能如何临时设置此配置?我不想将其设置为 ~/.ssh/config
.
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8,OpenSSL 1.0.1f 2014 年 1 月 6 日
对 ssh_config
使用不同的位置只会影响 ssh
的第一次调用,但不会影响第二次调用(也来自 ProxyCommand). You need to pass the same argument to the second
ssh`:
ProxyCommand ssh -F xy_conf -W %h:%p host1