101

From time to time, SSH sessions to my servers just freeze up and then neither Ctrl+C nor Ctrl+\ do anything.

How do I quit the session without just closing the Terminal it's in?


Clarification:

The session is locked as in, no keys are transmitted to the server. I'd like to shut it down gracefully, such that the user isn't logged in anymore.

I know I can kill the SSH client, but that will, in time, make the "2 users" info message I get from uptime meaningless. I'd like to know how many users are really logged in.

Stefano Palazzo
  • 85,787
  • 45
  • 210
  • 227
  • 2
    If you force quit your ssh session, the `bash` process on the remote server should be killed, causing you to log out. None of my servers keep me logged in after the SSH connections freeze (I'm using the default settings). – Andrew Gunnerson Jul 14 '11 at 23:18

2 Answers2

151

To disconnect a locked-up ssh session, typeEnter ~.

A full list of escape codes can be found in the ssh manpage or by typing ~?.

ravery
  • 6,824
  • 5
  • 21
  • 40
dirk
  • 1,722
  • 1
  • 11
  • 7
66

Type the following key sequence: Enter, ~, .. On US keyboards, the tilde (~) is Shift+`.

Jacob
  • 779
  • 5
  • 6