我想询问您的想法,我们的网络设置有些复杂,我需要连接到数十个 linux 盒子,有时需要对它们进行远程重启,但在我什至可以连接到目标 linux 盒子之前,我必须首先登录 2 个服务器,然后才能连接到目标 linux 机器,举个例子:
ssh to server 1
- usr/pwd
-- ssh to server 2
--- ssh to target linux box
- usr/pwd
- sudo reboot
有办法绕过这种方式吗?
答案1
在较新的 openssh 客户端中,您有一个ProxyJump
选项。
-J [user@]host[:port]
Connect to the target host by first making a ssh connection to the jump host and then establishing a TCP forwarding to the ultimate destination from there.
Multiple jump hops may be specified separated by comma characters. This is a shortcut to specify a ProxyJump configuration directive.
在 .ssh/config 中,它看起来像这样:
Host targetbox
ProxyJump server1,server2