If you want to connect to a local workstation behind a firewall you can do that by bouncing traffic off of an AWS instance.
An example would be accessing a Jupyter Lab from the outside world to a machine with no static IP or behind a firewall.
The steps are:
- Create a paid AWS Ubuntu instance and save the '.pem' file.
- Make sure the AWS instance's
Security Rules
allows traffic in. - Test that you can connect to this instance from the outside world (e.g.
python3 -m http.server
orjupyter lab --ip=*
) then visit the instance using its public IP. - (optionally) Enable password login in
/etc/ssh/sshd_config
by settingPasswordAuthentication yes
andsudo passwd $USER
. - Enable
GatewayPorts yes
and restartsshd
. E.g.sudo nano /etc/ssh/sshd_config
thensudo systemctl restart ssh.service
. - On the local workstation (e.g. GPU workstation) run the following command:
ssh -i "YOUR_PEM_FILE.pem" -R AWS_PUBLIC_IP:2222:localhost:8888 ubuntu@AWS_PUBLIC_IP
Now you can access the webserver or jupyter lab by going to http://AWS_PUBLIC_IP:2222
.
Warning: this guide does not take care of the security aspects. Use at your own risk.
And since it tends to disconnect randomly, you may want to put it in a loop
sudo `while sleep 1; do ssh -i tunneling.pem -R ubuntu@AWS_PUBLIC_IP:2222:localhost:8888 ubuntu@AWS_PUBLIC_IP || sleep 1 ;done`