Use SSH escape sequences and codes
Learn how to use SSH escape sequences to manage, suspend, resume, and terminate active connections.
Lesson Content
SSH supports escape sequences that let you control an active connection from your terminal. Each sequence starts with the escape character, which is ~ by default, followed by another character.
If an SSH connection becomes frozen, use ~. to terminate it and return to your local terminal:
~.The escape sequence must be entered at the beginning of a new input line. You can use it even when the remote terminal appears stuck.
You can also keep an SSH connection open without occupying your current terminal window. Press ~, then Ctrl+Z:
~^ZThis suspends the SSH session and returns you to your local shell. When you want to reconnect to the suspended session, use fg and press Enter:
fgThe fg command brings the most recently suspended job back into the foreground, restoring your SSH session.
Join the discussion!
Comments
Want to comment on this lesson?
Log in to leave comments.