Take the 2-minute tour ×
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
add comment

1 Answer

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:127.0.0.1:15901 user1@Host1 ssh -L 15901:127.0.0.1:5901 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:127.0.0.1:15901 user1@Host1 ssh -L 15901:127.0.0.1:5901 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 this:i.imgur.com/wns0q.jpg –  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
add comment

Your Answer

 
discard

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.