~/.ssh/config
我的本地机器上有以下文件:
Host head
User Marry
HostName xxx.xx.xxx.xx
Host machine1
User Marry
HostName xxx.xxx.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
Host machine2
User Marry
HostName xxx.xxx.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
Host machine3
User Marry
HostName xxx.xxx.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
Host machine4
User Marry
HostName xxx.xxx.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
我可以成功执行ssh machine1
、、ssh machine2
我ssh machine3
的本地机器,并转到机器 1-3,但对于机器 4,命令ssh machine4
失败:
ssh_exchange_identification: Connection closed by remote host
怎么会这样呢?
更新:按照muru的建议,删除2> /dev/null
,当我ssh到machine4时,我收到了消息:
bash: nc: command not found
ssh_exchange_identification: Connection closed by remote host