Kill An Unresponsive ssh Session Without Closing The Terminal

If you log into an ssh terminal and then lose connection to the server (or the internet) then it can leave you hanging. To close the connection and keep the terminal open run through the following steps:

  • Press Enter to clear your terminal and ensure the next command is run independently.
  • Press ~ (tilde)
  • Press . (full stop)

Your ssh session will close, dropping you back to your local terminal.

There are variations to this.

  • Some interfaces might require you to press Enter again after pressing ..
  • If you have an interface that intercepts accented characters then you might need to press ~ twice to get a single ~ to be shown correctly.

Add new comment

The content of this field is kept private and will not be shown publicly.