Skip to content

Instantly share code, notes, and snippets.

@spestana
Last active July 29, 2020 18:19
Show Gist options
  • Save spestana/002640580d6ab84fae941f51b74b1537 to your computer and use it in GitHub Desktop.
Save spestana/002640580d6ab84fae941f51b74b1537 to your computer and use it in GitHub Desktop.
Notes on setting up remote connection to a jupyter notebook server

Notes on setting up remote connection to a jupyter notebook server

Configure the server and password:

On the remote machine:

  • Check to see if you have a notebook configuration file jupyter_notebook_config.py
    • On linux this is typically located at /home/USERNAME/.jupyter/jupyter_notebook_config.py
  • If you don't have this file, generate it with the command:
jupyter notebook --generate-config
  • Set up a password with jupyter notebook password

Starting the server:

On the remote machine:

  • jupyter notebook --no-browser --port=8080

On your local machine:

  • ssh -N -L 8080:localhost:8080 <remote_user>@<remote_host>
  • Open a web browser to http://localhost:8080/ and log in using your password

Using alias commands:

Edit the .bashrc files on your local and remote machines with alias commands to make launching a notebook easier.

On the remote machine:

alias jnb="jupyter notebook --no-browser --port=8080"

On your local machine:

alias jnb="ssh -M -S jnb-socket -fNT -L 8080:localhost:8080 <remote_user>@<remote_host>; start http://localhost:8080/"
alias jnbchk="ssh -S jnb-socket -O check <remote_user>@<remote_host>"
alias jnbext="ssh -S jnb-socket -O exit <remote_user>@<remote_host>"

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment