Skip to content

Remote Jupyter Notebook Connection Guide

Oren Mishali edited this page Nov 21, 2024 · 1 revision

Remote Jupyter Notebook Connection Guide

1. Log into Remote Machine (recommended: use MobaXterm)

ssh username@remote_machine_ip

2. Prepare Project Environment

# Create project folder
mkdir myproj
cd myproj

# Create Python virtual environment
python3 -m venv env

# Activate virtual environment
source env/bin/activate

3. Install Jupyter

# Install Jupyter within virtual environment
pip install jupyter

4. Launch Jupyter Notebook

# Option 1: Direct Launch (Not Recommended for Long Sessions)
jupyter notebook --no-browser --port=8888 --ip=0.0.0.0

# Option 2: Using Screen (Recommended for Long-Running Sessions)
screen -S jupyter_session
jupyter notebook --no-browser --port=8888 --ip=0.0.0.0
# Press Ctrl-A, then D to detach from screen
# Use 'screen -r' to reattach

5. Connect from Local Machine

  1. When Jupyter launches, it will print a URL that looks like: http://localhost:8888/?token=some_long_token

  2. Replace localhost with the remote machine's IP address Example: http://123.456.789.10:8888/?token=some_long_token

  3. Open this modified URL in your local web browser

6. Useful Screen Commands

# List active screen sessions
screen -ls

# Reattach to a detached session
screen -r session_name

# Kill a screen session
screen -X -S session_name quit

Security Recommendations

  • Always log out and close connections when not in use

Clone this wiki locally