Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

I have the following configuration and want to establish a tunnel on a tunnel. I read already the following topic: How to put a tunnel in a tunnel?

My configuration:

Notebook --> Linux Server A --> Linux Server B

Notebook: Windows XP with putty
Linux Server A and B: Ubuntu 10.10

I have a ssh connection with a tunnel from my notebook via putty to Server A. Now I want to establish a tunnel from Server A to B, so that I can connect with an IDE directly to my jboss on Server B.

This is the command I tried on Server A to establish a tunnel:

ssh -t -L 8080:localhost:8080 Server B -p 8822

This won't work.

Anybody an idea how to establish a working tunnel?

share|improve this question
up vote 6 down vote accepted

What you're looking for is called "ssh multi-hop". It is quite possible to do this transparently, using the ProxyCommand directive in .ssh/config (or an equivalent config option in PuTTY, or what-have-you):

Host linux-server-b
  ProxyCommand ssh -q linux-server-a nc -q0 linux-server-b 22

What this does, when you try to connect to linux-server-b:

  • opens a SSH connection to linux-server-a
  • runs netcat there, and opens a TCP connection to linux-server-b
  • forwards this connection back to you

This way, you can use all the features of SSH, as if you were connected to linux-server-b directly; you can even chain multiple hops together (server A to server B to server C to server D ...)

See also:

share|improve this answer
Thanks, I will try it. – LStrike Jan 24 '12 at 8:44
Problem solved, Thank you – LStrike Jan 24 '12 at 10:01

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.