jupyter notebook external host code example

Example 1: jupyter on remote server

0. [remote] move to the desired folder (root of the future jupyter server)

1. [remote] [optional] create a screen for the server,
   so you can close the remote terminal and jupyter will keep running

   screen -S jupyter

2. [remote] start jupyter, with no browser, on port RRRR

   jupyter notebook --no-browser --port=RRRR

3. [remote] look at the output and take note of the token in
   http://localhost:RRRR/?token=07994b9f01b2bb2ff3bd6a0fdef2c1294863165c7ba9c6b4

4. [remote] [optional] detatch from screen
   
   Ctrl+A, D

5. [local] on terminal, connect local port LLLL to remote port RRRR

   ssh -NfL localhost:LLLL:localhost:RRRR [email protected]
   (type password for [email protected])

6. [local]
   open browser on page "localhost:LLLL"
   you will see the login page for jupyter
   type the token from step 3.

NOTES:
If possible RRRR = LLLL = 8888, makes everything easier
Do NOT close the local terminal until you are done
Local terminal might disconnect the ports some times: just repeat step 5.
[optional] Remember to exit the screen on remote once you are done

Example 2: jupyter notebook change ip address

# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 9999