Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Laptop(osx-home network)------>Host1(linux-pc-college network)---->Host2(linux-pc-using vncserver on port 5901, can only be accessed from host1)

I can access host2 through ssh using:

  • [user@laptop ~]$ ssh user1@host1
  • [user1@host1 ~]$ ssh user2@host2

I need to access host2 vncserver using a ssh tunnel from "laptop". Any recommendation, also, which vnclient is suitable for this task?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Several options are available. First you need to setup a TCP tunnel.

If the port forwarding to the local network is not disabled in the sshd_conf at host 1, then this would be enough:

ssh -t -L 5901:ip-of-host2:5901 user@Host1

Otherwise you need to build a chain of port forwardings:

ssh -L 5901: user1@Host1 ssh -L 15901: user@host2

if the password authentication is used to connect to host2 then add a -t option to the first ssh:

ssh -t -L 5901: user1@Host1 ssh -L 15901: user@host2

Then use vncviewer of your choice to connect to the display localhost:1. I prefer to use TigerVNC.

share|improve this answer
Thanks @serge that worked. Now I just need to config vncserver. It displays file manager windows like –  bownana Oct 21 '12 at 11:23
I don't know why. I have no experience with Mac –  Serge Oct 21 '12 at 11:37

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.