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?
How can I break away from an SSH session that has crashed?
ssh;terminal
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 thatYou should also remember to press Enter before ~. The escape character works when it is the first character in the line. And also you can use ~ and later ? to get help from the ssh client. (Thanks to the comment by Lukasz Stelmach.)