Many times I have an SSH session that doesn't respond anymore (for example, when I lose internet connection and then reconnect). Ctrl+C, Ctrl+D, Ctrl+Z and a zillion of key presses don't have any effect.
Most of the time I already have tmux
or byobu
running already, so I can just start another terminal and reconnect. However it does feel cumbersome. How can I disconnect SSH from the current terminal?
Best Answer
Use the "escape character" (normally, the tilde
~
) to control an SSH session:~
followed by.
closes the SSH connection;~
followed by Ctrl+Z suspends the SSH process;~
followed by another~
sends a literal~
.You can set the escape character using the
-e
option to ssh.Additionally, remember that