Last Updated: January 04, 2021
·
2.595K
· bjeanes

Easily kill a flooding SSH connection and other awesome SSH things

This tip is for when your SSH connection is being flooded (perhaps you accidentally ran cat /dev/rand or something) and your ^C presses don't seem to be getting through.

If this ever happens to you, you can simply type <enter>~. to abort the connection. This will always work because that key sequence is sent to your local SSH client process, not to the server.

~ (tilde) is the SSH's default EscapeChar. You press <enter> first to clear the buffer, the ~ escape char and any one of a number of options.

For example, the full list of options that the client of my version of OpenSSH supports is (gotten with <enter>~?):

Supported escape sequences:
  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice

2 Responses
Add your response

For anyone else that misread the tilda as a hyphen, it is a tilda ~, not a hyphen -.

over 1 year ago ·

Ah good point! Updated the post to explicitly point out which character it is.

over 1 year ago ·