Running Jupyter on a Remote Server and Connecting Locally
How to run Jupyter on a remote server and connect to it locally, using SSH tunnels.
Create a tmux or screen session on the remote server
# tmux
tmux new -s jupyter
# screen
screen -S jupyter# tmux
tmux new -s jupyter
# screen
screen -S jupyterStart Jupyter on the remote server
jupyter notebook --no-browser --port=8889jupyter notebook --no-browser --port=8889Note: Copy the token from the output of the above command and save it somewhere.
Detach from the tmux or screen session
# tmux
Ctrl + b, d
# screen
Ctrl + a, d# tmux
Ctrl + b, d
# screen
Ctrl + a, dCreate an SSH tunnel from the local machine to the remote server
ssh -N -f -L localhost:8888:localhost:8889 user@remote-serverssh -N -f -L localhost:8888:localhost:8889 user@remote-serverOpen Jupyter in the browser
Open http://localhost:8888 in the browser and enter the token from earlier.
Reattach to the tmux or screen session
# tmux
tmux attach -t jupyter
# screen
screen -r jupyter# tmux
tmux attach -t jupyter
# screen
screen -r jupyterKill the tmux or screen session
# tmux
tmux kill-session -t jupyter
# screen
screen -X -S jupyter quit# tmux
tmux kill-session -t jupyter
# screen
screen -X -S jupyter quit