Search code examples
sshssh-tunnelsecure-crt

How to SSH to a server then to another within same tab?


I have two remotes servers (Server_01 and Server_02).

My work literally is on Server_02. In order to access to Server_02, I need the first SSH to Server_01 then another SSH to Server_02.

(machine)$ ssh Server_01
(Server_01)$ ssh Server_02
(Server_02)$ ...

I would like to make things easier where I could use SecureCRT or terminal tab on-click to SSH to Server_02.


Solution

  • You are searching for ProxyCommand.

    ssh Server_02 -o ProxyCommand='ssh Server_01 -W %h:%p'
    

    or even better add Server_02 to your ~/.ssh/config

    HOST Server_02
      user <myUsername>
      ProxyCommand ssh Server_01 -W %h:%p
    

    Then you can simply use ssh Server_02 from your local machine