How can I break away from an SSH session that has crashed?

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

You 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.)

Tags:

Terminal

Ssh