Short answer: Type
If that doesn't work, however...
SSH Escape Character
Most SSH implementations implement an escape character for interactive sessions, similar to telnet's
Ctrl-] combination. The default SSH escape character is
~, entered at the beginning of a line.
If you want to terminate an interactive OpenSSH session which is stuck and cannot be exited by entering
exit or CtrlD into a shell on the remote side, you can enter
~ followed by a dot
.. To be sure to enter the escape character at the beginning of an input line, you should press Enter first.
So the following sequence will in most cases terminate an SSH session:
Other Escape Sequences
OpenSSH, for example, offers other escape sequences besides
~? during a session should give you a list. Some examples:
Ctrl-Z suspends the session,
~& puts it directly into background,
~# gives a list of forwarded connections in this session.
- If you want to simply enter a tilde at the beginning of a line, you have to double it:
The escape character can be changed using the command line option
-e. If you set the special value
-e none, escaping is disabled and the session is fully transparent.
See also the OpenBSD man page on ssh (which is referenced from www.openssh.org) under the
-e command line option