
yuuka_maniaの日記: 多段 ssh 3
日記 by
yuuka_mania
ref.
https://www.redhat.com/sysadmin/ssh-proxy-bastion-proxyjump
いろいろある模様。
ssh -J <bastion-host> <remote-host>
さらに多段だと、
ssh -J <bastion1>,<bastion2> <remote>
なんてのもあるようだ。
.ssh/config に ProxyJump を書く方法もある。個人的には、これが一番良さそう。
Host humidai
HostName humidai.example.com
Host target
HostName target.example.com
ProxyJump humidai
最後は、ProxyCommand を使う方法
ssh -o ProxyCommand="ssh -W %h:%p bastion-host" remote-host
%h は、リモートホストになり、%p は、リモートホストのポート番号になる。
-W は、stdin と stdout を、転送する。
.ssh/config に書く場合は、
Host target
ProxyCommand ssh humidai.example.com -W %h:%p
しらんかった (スコア:0)
あんまりその手の作業はしないけど、多段でやるときは単に ssh 繰り返して並べてました
ssh user@fumidai ssh user@host command
Re:それでOK (スコア:0)
それでOK
効果はおなじ
Re: (スコア:0)
公開鍵認証する場合は少し違ってくるはず。ssh user@fumidai ssh user@host commandだと、ssh user@hostはfumidai内の~/.ssh/id_〇〇が使用される。ssh -JやProxyCommandの場合、踏み台もその先のサーバーにも自マシンの~/.ssh/id_〇〇が使用されるということになる。