Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to list the tunnels that SSH clients connected to my OpenSSH server have set up?

I can use e.g. lsof -i to show connections that are being actively tunnelled, but I'd like to be able to list tunnels that the clients have set up but may not currently be in use.

(It's just struck me that this may be an entirely client-side thing, i.e. the server only knows the client is set up to tunnel a port when something tries to connect through the tunnel, in which case the answer will be "you can't" - but I'll take that as an answer if so.)

(Background: I'm running a MineCraft server on a machine that won't be able to do much else while it's running. If I can monitor when users have tunnels set up, I can run up the MC server on demand.)

share|improve this question
I have a strong suspicion that you actually aren't talking about tunnels. – Let_Me_Be Nov 30 '11 at 20:51
I don't see how my use-case is so outlandish. Tunnelling ports to localhost isn't too unusual, and isn't really relevant to the question. All I want to know is whether the server providing the tunnel is aware the tunnel is there between the SSH connection being made and the tunnelled connection being made, and if so, how to get a list of these tunnels. – Rawling Nov 30 '11 at 21:21
up vote 1 down vote accepted

Well yes it is client sided.

Plus there isn't any configuration in the traditional sense. You create a tunnel by specifying the correct parameters when connecting to a server.

Sure you can store it in .bashrc, .ssh/config, or some other place for re-usability, but in general it is purely on-demand.

share|improve this answer
You say "specifying the correct parameters when connecting to a server". Do you mean when you make the original SSH connection, or when the e.g. MC client connects to (client) localhost and gets tunnelled to the server? If its the former, that means the server is aware of the potential tunnel even when it's not being tunneled through. If it's the latter then the server knows nothing about the potential tunnel until the tunneled client connects. – Rawling Nov 30 '11 at 20:16
@Rawling Well, if you run ssh -L 5000:mail_server.cz:110 ssh_account.cz then it will create a tunnel going from your local port 5000 through the ssh_account.cz machine to the port 110 on mail_server.cz. If you run ssh -R 80:localhost:800 ssh_account.cz it will create a tunnel going from the port 80 on ssh_account.cz to your local port 800. – Let_Me_Be Nov 30 '11 at 20:39
@Rawling And these tunnels, won't exist until created. – Let_Me_Be Nov 30 '11 at 20:39
So the server knows literally nothing about the tunnels until the e.g. mail client/web client actually uses them? In which case... bad news for my use case, but at least it's an answer. – Rawling Nov 30 '11 at 20:45
@Rawling Uh? What do you mean by: "mail client/web client uses them"? If you are routing mail/web traffic through a tunnel, that tunnel has to be created before you do that (manually). – Let_Me_Be Nov 30 '11 at 20:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.