0

normally I use this kind of script (this is part of a larger bash script) to connect my pc to a static-ip pc and run a jupyter notebook remotely:

sudo fuser -k 8881/tcp
echo 'Port 8881 is free now'
ssh -N -f -L localhost:8881:localhost:8888 $username@$servername 
read -p 'SSH Tunnel created - Press enter to continue'
ssh $username@$servername 'nohup jupyter notebook --no-browser --notebook-dir="$notebookdir"'
wait
echo 'Please, wait some seconds.'
$nohup $browser http://localhost:8881/

And it works. But now I need to access a third pc that have a dynamic ip and I cant use services like dyndns. One good solution is to create a simple VPN like was done here SSH connection between two behind-nat computers through third public-ip computer.

This means that I have to do in the remote pc (dynamic-ip pc):

ssh -R 20000:127.0.0.1:22 user@RemoteHost 

On my local pc (which also have a dynamic-ip):

ssh -L 8000:127.0.0.1:20000 user@RemoteHost

And finally, if I do:

ssh 127.0.0.1 -p 8000

This creates the "VPN". But now I'm a little lost on how to run the jupyter notebook forwarding a port in away that I can use the jupyter notebook of my remote pc on my local browser, using the remotehost with static-ip as a bridge.

Any suggestions or tips are welcome. Thank you.

1

While it is doable to set up SSH with the jumper box (machine with static IP), I'd personally recommend to set up Zerotier on all three machines: then, one simple command will make the Jupyter-server-port available "locally" as each of the machines will have a "static" IP.

Before I learned about Zerotier, I was hosting exactly what were describing. Here are a few hassles that I am aware of.

  1. On the host for Jupyter Server, a cron-job needs to run first to make the port available to the jumper box;
  2. On the client machine, it is nevertheless needed to fetch the port from the jumper machine.
  3. If anything in between fails, chances are that the JupyterLab instance will stop working. It is yet another hassle to troubleshoot what went wrong.

With a Zerotier setup, only the #2 step is necessary, and the latency is comparable to jumping through multiple SSH tunnels (and reverse-tunnels).

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.