I have two machines, client and server.  client has created a reverse-tunnel on server with something like ssh -R 12345:localhost:12345 server.When logged into server how could I find ports which have been bound to tunnels?  So, in the above example, how could I tell that port 12345 was in use as a tunnel to client?
How can I tell which ports have been used for reverse SSH tunnels?
ssh;tcp;ssh tunneling
You can do that by using lsof to check which TCP ports are in state LISTEN and used by sshd:[jenny@willow ~]$ sudo lsof -iTCP -sTCP:LISTEN | grep sshdsshd       1084     root    3u  IPv6 0xffffff0003fed888      0t0  TCP *:ssh (LISTEN)sshd       1084     root    4u  IPv4 0xffffff0003fed5b0      0t0  TCP *:ssh (LISTEN)sshd      47607    jenny    7u  IPv6 0xffffff00510a0888      0t0  TCP localhost:12345 (LISTEN)sshd      47607    jenny    8u  IPv4 0xffffff00410062d8      0t0  TCP localhost:12345 (LISTEN)The top two are the SSH daemon, the two below are a TCP tunnel. (Each one is listed once for IPv6 and once for IPv4).