Skip to content

Did you know?

Enter, then ~. closes a frozen SSH session instantly.

No need to close the terminal window. ~? lists the other escape commands.

Explained

When the network drops, an SSH session often just freezes: no prompt, and Ctrl+C does nothing because the keys never reach the server. The SSH client itself can end the connection. Press, in this order:

  1. Enter
  2. ~ (tilde)
  3. . (period)
~.
Connection to server.example.com closed.

The escape character only works at the start of a line, which is why you press Enter first. Other escapes: ~? lists them all, ~^Z suspends the SSH client, and ~# lists forwarded connections.

In a nested session (SSH into one server and from there into another), ~~. closes the inner connection and leaves the outer one open, because ~~ sends a single tilde through.

To make dropped connections less likely in the first place, add ServerAliveInterval 60 to ~/.ssh/config.

Learn more

← All tech tips · Suggest a fix

Back to top