Multi-hop SSH by one-liner / 多段SSHワンライナー
Since I always forgets to how to make "multi-hop ssh", I'll summarize it in this article. I'll write some config in .ssh/config if a topology is fixed but I won't if a topology is formed temporarily.
If there is a network depicted as below,
client ---- jump-server-01(10.0.0.1) ---- jump-server-02(172.16.0.1) ---- target-server(192.168.0.1)
you can use this command to ssh to the "target-server".
ssh shoutm@192.168.0.1 \
-oProxyCommand=“ssh -W 192.168.0.1:22 shoutm@172.16.0.1 \
-oProxyCommand=\”ssh -W 172.16.0.1:22 shoutm@10.0.0.1\” "
I hope it helps