Did you know?
Enter, then ~. closes a frozen SSH session instantly.
No need to close the terminal window. ~? lists the other escape commands.
- Security & SSH
- Last checked
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:
- Enter
- ~ (tilde)
- . (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
- How To Set Up SSH Keys in Linux Full guide · Updated Apr 2025
-
sshcommand cheat sheet Options and copy-ready examples
