Run jupyter notebooks remotely over ssh

  • Make sure you have ssh keys to allow for password-less login (see DO guide for how to do that)
  • Run the vpn agent if your server is behind a firewall
  • On the server run the jupyter notebook in headless mode using a command
    jupyter notebook --no-browser --port=8080
    Resulting in something like
    http://localhost:8080/?token=88495a69a74a90e62ada1388c4abc30606474df18131bf67 Copy this command as you will need it later !!
  • On the client side (your laptop), create an ssh tunnel using
    ssh -N -L localhost:8080:localhost:8080 username@server_ip_address
  • Open Firefox (or any browser) on the client side (your laptop) and type
    http://localhost:8080/?token=88495a69a74a90e62ada1388c4abc30606474df18131bf67 using the same token you got from step above

Please Note that the choice of the ports on both sides doesn’t have to be the same and the local port 8080 is arbitrary and the port 8080 on the server have to be open and listening/traffic is allowed through the vpn on that port. Also please note that this token will different every time you run the jupyter command. BTW, I usually use

nohup jupyter notebook --no-browser --port=8080 >> jupyer_key.log 2>&1 &