Lets assume this state (imageshack image) of network. I want to SSH-tunnel connection between VNC clients and VNC servers.

enter image description here

Both PC1 and PC2 runs TightVNC server and SSH server and have allowed ports 22. PC client want to connect to PC1 using TightVNC Java viewer. What addresses need to be entered into TightVNC Java viewer (Remote Host? Port? SSH Server?) What configuration need to be made to router to forward to right PC? Thanks for your answers.


At first you have to set up port forwarding on your router. Let's play this through using ssh as example (every other protocol would work the same).

If you had only one machine you could simply forward port 22. Since you can forward a port only to one machine this is not an option in your case. Make up two port number for your machines. In this case I will use 10022 and 20022. Now you have to set up two forwardings on your router:

  • One from external port 10022 to internal ip & port
  • One from external port 20022 to internal ip & port

This means that every external request on port 10022 goes to port 22 (ssh) of your PC1.

From your external PC you now need two ssh connections to IP Note that those connections can't work on default port 22 but on 10022 and 20033.

The same can be done with every other protocol/service. Just replace the port 22 with the port of that service.

Alternatively you can tunnel every service through ssh. I don't know the tighVNC port but let's assume it's 9000. You can set up the tunnel to PC1 with:

ssh -L 9001:localhost:9000 user@

This connects to PC1 via ssh and forwards the adress localhost:9000 (from the view of PC1) to the port 9001 of the machine you execute this on. I choose 9001 so that you could forward tightVNC from PC2 at the same time:

ssh -L 9002:localhost:9000 user@

Now you can connect tightVNC from your remote machine using the addresses localhost:9001 and localhost:9002.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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