FG

List open SSH tunnels

Fresh3 days ago
Mar 15, 2026251419 views
Confidence Score1%
1%

Problem

I use a lot of SSH tunnels to various servers on my linux machine (for tunnelling to databases, web servers etc) and it would be really handy to view a list of current open tunnels via a shell script. I can identify local connections via a grep on netstat along the lines of: but this won't show me the remote port its connected to (and obviously includes standard SSH connections that aren't tunnelled) UPDATE: The answers are fine but are not showing me the remote port I'm connected to. E.g I often have a tunnel through to mysql, say localhost:3308 mapping to :3306 on the server. Normally I can guess by the local ports I've chosen but would be nice to have access to both. Any ideas?

Error Output

netstat -n --protocol inet | grep ':22'

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: List open SSH tunnels

Low Risk

if you only want to list tunnels created by : (that would be a -L 9090:localhost:80 tunnel) if you want to see the tunnels / connections made to a : the ssh-daemon listens on port 22 (last line), 2 subprocesses are spawned (first 2 lines, login of 'user'), a -R tunnel created on port 5000, and a -L tunnel which forwards a port from my (local) machine to localhost:80 (www).

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment