Access to Jupyter Lab/Notebook on Remote Server

This tutorial documents the way to set up access to Jupyter Lab or Jupyter Notebook on your remote server from your local computer.

Set up password

On your server,

jupyter notebook --generate-config
jupyter notebook password

Enter your password of choice.

Using SSL for encrypted communication

cd ~/.jupyter
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem

Change public notebook server configuration

Open ~/.jupyter/jupyter_notebook_config.py with a text editor (ex. vi) and add the following lines

# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'~/.jupyter/mycert.pem'
c.NotebookApp.keyfile = u'~/.jupyter/mycert.pem'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:bcd259ccf...<your password of choice here>'
c.NotebookApp.open_browser = False
# Set a known, fixed port for server access
c.NotebookApp.port = 9999

Run Jupyter Lab or Notebook

jupyter lab
or
jupyter notebook

Forward remote port to loacalhost

ssh -N -f -L 8888:localhost:9999 [email protected] 

Access from local browser

Open a browser on your local computer and navigate to https://localhost:8888/.

Keng-Chi Chang
Keng-Chi Chang
Postdoctoral Scholar, UC San Diego
comments powered by Disqus

Related