Site icon New Generation Enterprise Linux

Add a port forward to a live SSH session

SSH & Remote Administration

Add a port forward to a live SSH session

🧩 The Challenge

You’re already deep into a remote server, maybe a jump box or a production host, and suddenly realize you need to hit some internal service that’s only reachable from there. But you forgot to set up that port forward when you connected. Now you’re staring at an `ssh -L` command you wish you’d run, and the thought of disconnecting, re-running, and reconnecting is just draining.

💡 The Fix

There’s a quick escape sequence in your SSH client that lets you add port forwarding right into your existing session. It’s a lifesaver when you need to quickly expose an internal web app or database to your local machine without breaking your workflow.

~C
L 8080:localhost:80

⚙️ Why It Works

When you type a tilde (~) as the very first character on a line, your local SSH client intercepts it. The capital ‘C’ then tells it you want to enter the command prompt. From there, you can type ‘L’ followed by your port forward specification, just like the `-L` option you’d use on the command line, and your session gets the new tunnel.

🚀 Pro-Tip: Need to kill a hung SSH session without closing your terminal? Try `~.` (tilde, then a dot) for an instant disconnect.

Linux Tips & Tricks | © ngelinux.com | 9/21/2026

0 0 votes
Article Rating
Exit mobile version