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:
netstat -n --protocol inet | grep ':22'
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?