0

In my home network I have a PC, raspberry pi, macbook and a few other devices which I want to access away from home.

As it stands, I have setup VNC server on my PC along with remote desktop and have changed the default ports. These ports are open on my router and redirect to the PC so that I can access them via dynamic dns.

However I was wondering if it was possible to close those open ports on the router, and instead leave only port 22 on the raspberry pi so I can use an SSH tunnel through the pi, to the PC and run VNC through that?

If so how would the command prompt look? I understand vaguely how SSH tunnels work and can use them applying to 1 remote host, i.e:

ssh -L 22222:localhost:5900 user@pi

then running localhost:22222 in my vnc viewer will let me connect to the pi.

Reading up on the subject suggests I could do something like ssh -L 22222:internal_pc_ip:5900 user@pi and run localhost:22222 like before?

Can I do this?

2
  • 1
    I think you'll need an uppercase -L in your ssh command to establish tunnel.
    – Ketan
    Commented Feb 5, 2014 at 18:45
  • You're right, sorry about that it completely slipped my mind.
    – gray_fox
    Commented Feb 5, 2014 at 18:50

2 Answers 2

1

Your approach looks ok to me.

If so how would the command prompt look?

You will actually be connected to your pi after the ssh -L command. You will get the prompt that you have on your pi device. Keep this connection open to forward all the traffic from localhost:5900 of your pi device to port 22222 of the device from where you are ssh'ing. To have multiple tunnels, I think you will need a new localport. So, may be replace 22222 with 33333.

0
0

This is the command I use: ssh -L 5901:127.0.0.1:5901 -N -f -l username server_ip_address

Keep in mind you will have to add a source nat to iptables and also enable IP forwarding in the pi.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .