AMBER Tutorial

Using Jupyter notebook securely in remote cluster

By Hai Nguyen (BSD 2-clause)

Motivation

Your data (may be TB) is in your remote cluster. You want to access and interactively play with your data in Jupyter notebook. You can use xwin to open your Jupyter notebook on remote host. However, this kind of connection is quite slow.

You can follow each step below to have fast connection via SSH port forwarding.

1. In remote cluster

(remote cluster is where you store your data)

- cd /to/your/working/folder
- amber.jupyter notebook --no-browser --port=8000

Note: Use can specify any available port number

You will see something similiar to below

$ amber.jupyter notebook --no-browser --port=8000
    [I 15:12:45.032 NotebookApp] Serving notebooks from local directory: /u1/haichit/tutorials
    [I 15:12:45.032 NotebookApp] 0 active kernels 
    [I 15:12:45.032 NotebookApp] The Jupyter Notebook is running at: http://localhost:8000/
    [I 15:12:45.032 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [I 15:15:51.028 NotebookApp] 302 GET / (127.0.0.1) 1.66ms

2. In your local machine (Windows, Mac laptop, ...)

  • Open your terminal and type:

    ssh -N -f -L localhost:8000:localhost:8000 your_account@your_cluster_address
    

    Note: replace "your_account@your_cluster_address" to your real login account (e.g: hc@fancy.rutgers.edu)

  • Now open web browser, type "localhost:8000"

  • click "New" to create a new notebook

  • Type the command in each cell and then hit Shift-Enter to run and to create new Cell.