Video Lesson: Use SSH escape sequences and codes

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:

~^Z

This 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:

fg

The fg command brings the most recently suspended job back into the foreground, restoring your SSH session.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Log in for AI tutor access.

Comments

Join the discussion!

Notes

Keep track of what you learn!