可能的重复:
如何使用 ssh 通过另一台电脑连接到另一台电脑
如何在一个命令行中执行以下操作?
$ ssh 服务器一 $ su - 用户 $ ssh 服务器二
当然我不能直接ssh user@server-two
答案1
ssh server-one -t ssh user@localhost -t ssh server-two
从man ssh
:
-t Force pseudo-tty allocation. This can be
used to execute arbitrary screen-based programs
on a remote machine, which can be very useful,
e.g. when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
答案2
ssh -t server-one 'su - user -c "ssh server-two"'