Most of the people don’t know this option, its very useful for server administrator.
You can assume the scenario : you are having 2 server’s both server having the firewall, you are trying to Login remotehost-2 with wrong password more then 3 times the public IP (Static IP) was blocked on remotehost-2 that time you have no option to access the remotehost-2 without removing the IP from remotehost-2 firewall. The quick and easy way to do it by login from remotehost-1 to remotehost-2 and perform the action.
You can also use the SSH Escape Character to work both server with single ssh session without login and logout both server.
When you’ve logged on to the remotehost-2 using ssh from the remotehost-1, you may want to come back to the remotehost-1 to perform some activity and go back to remotehost-2 again. In this case, you don’t need to disconnect the ssh session to the remotehost-2. For better understanding follow the below steps.
STEP-1:
Now, I’m in remotehost-1
login as: root [email protected]'s password: Last login: Wed Dec 4 05:51:28 2013 from 219.91.219.14 root@remotehost-1 [~]#
STEP-2:
Login to remotehost-2 from remotehost-1
root@remotehost-1 [~]# ssh [email protected] -p 2244 The authenticity of host '[83.170.117.139]:2244 ([83.170.117.139]:2244)' can't be established. RSA key fingerprint is 84:96:3e:b9:5e:95:a2:76:69:3f:0f:95:fb:10:09:7d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[83.170.117.139]:2244' (RSA) to the list of known hosts. [email protected]'s password: Last login: Wed Dec 4 05:50:03 2013 from 219.91.219.14 root@remotehost-2 [~]#
STEP-3:
To come back to the remotehost-1 temporarily, type the escape character ~ and (Control+Z).
Note : When you type ~ you will not see that immediately on the screen until you press
root@remotehost-2 [~]# ~^Z [suspend ssh] [1]+ Stopped ssh [email protected] -p 2244 root@remotehost-1 [~]#
STEP-4:
Now you are back to the remotehost-1 and the ssh remotehost-2 client session runs as a typical UNIX background job, which you can check as shown below
root@remotehost-1 [~]# jobs [1]+ Stopped ssh [email protected] -p 2244 root@remotehost-1 [~]#
STEP-5:
You can go back to the remotehost-2 ssh without entering the password again by bringing the background ssh remotehost-2 session job to foreground on the remotehost-1.
root@remotehost-1 [~]# fg %1 ssh [email protected] -p 2244 root@remotehost-2 [~]#
That’s it.