Friday, March 9, 2018

Putty to Pi, via a Jump Server, With X11, Tunnel-tastic

Senario: I have a Rasberry Pi I want to remote(SSH) to and run python GUI's from. The only public route to my Pi's is via the one public Pi that acts as a jump server.

Things I've already done:
  1. SSH with X11 activated on the Jump Server - (JS)
  2. A port forward from my home router to the SSH port on the Jump Server (JS)
  3. SSH with X11 activated on the Target Pi (tPi)
  4. A windows machine with Putty and XMing installed (Lappy)

First create a Putty session on Lappy to JS.

The IP address 66.66.66.66 is the IP (altered to protect the innocent) of the home router, Port 66 is the port on the router that has been forwarded to the SSH port on JS (this is all done in the config of the router)

 In Putty, expand the SSH section and select Tunnel,

The Source port (2222) is a the start of the tunnel and will be created on Lappy by Putty when this session is opened, the destination is the ip address of tPi inside my home network, and the port tPi uses for SSH.

What does this do? when the Putty session (I saved the details as gPiTunnel) is started Putty on Lappy uses SSH to connect to JS, it then creates a tunnel in the SSH session that starts at port 2222 on Lappy and ends at the SSH port of tPi.

Now create a Putty session to port 2222 on Lappy:

This seems odd at first, but in the previous step a tunnel was opened from 2222 through the interwebs and ending at tPi, this session by connecting to 2222, jumps through the tunnel and pops out at the SSH port on tPi, letting you log on to the Pi there.

Expand the SSH section of this second session, select X11 and enter the details below:

 This allows tPi to send X11 programs to the Xming service running on Lappy, port 0 is the display port. save this session as TunnelDoor.


To use it:
On Lappy run Xming, run Putty, load session gPiTunnel, log in. (user and password for JS)
Still on Lappy run Putty, load session TunnelDoor, log in. (user and password for tPi)

Now any X11 apps started on tPi in the Putty session will open and display on Lappy, to test it run xclock on tPi


And done, now I can cruft up my Python GUI in the tPi session, run it and the UI opens on Lappy