SSH Tunnels – How to Create an HTTPS SSH Tunnel on Linux

httpslinuxsshssh-tunnel

Ok so I have a web server, lets call it Server A, which is providing a service via HTTPS. And I have an SSH gateway server, lets call it Server B.

Due to firewall rules I cannot access Server A's web service from my desktop linux computer. Therefore to view the web service I must SSH with X Forwarding to Server B and run firefox over the SSH tunnel. Server B can access Server A's web service and so it works.

I'm wondering if it would be possible to create an SSH tunnel between my PC and Server B which would allow me to access the service on Server A using my desktop web browser rather than running firefox over the SSH tunnel.

Best Answer

Yes, it is possible:

ssh -L 8443:serverA:443 -Nf [user@]<serverB>

This will let you point your desktop browser at port 8443 and send it to port 443 (the HTTPS port) on your server A. The -Nf will background the session and exit immediately back to your desktop, not establishing an actual shell session to server B.