私の~/.ssh/config
ファイルは
Host head
User Marry
HostName xxx.xx.xxx.xx
Host machine1
User Marry
HostName xxx.xx1.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.xx2.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.xx3.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.xx4.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
しかし、より多くのマシンを手動で設定するのは面倒です。次のインスタンスをどのように設定しますか?
Host machine*
User Marry
HostName xxx.xx*.xxx.xx
IdentityFile /home/Marry/ssh_head_keys/id_rsa
ProxyCommand ssh head nc %h %p 2> /dev/null
ホスト名のアドレスは数字のみで異なるためです。
修正するTagwintの提案に基づいて、次のようになります。
ssh_exchange_identification: Connection closed by remote host
ベストアンサー1
ProxyJump
次のコマンドを使用してこれを実行できます。
Host machine1 machine2 machine3
ProxyJump head
必要に応じて、次のように2つのホストを介してデュアルホップを実行できます。
Host machine1 machine2 machine3
ProxyJump head,jump
または、次のようにドメイン内のすべてのエントリを一致させます。
Match host "*.example.com"
ProxyJump head,jump
現在のIPアドレスに基づいてこれを行うこともできます。
Match host "*.example.com" !exec "ifconfig | grep -q ' 172.16.1.40 '"
ProxyJump head,jump.example.com