Last active
November 15, 2016 07:00
-
-
Save denti/8c8308bbe83834ab39012b0d31ec8f73 to your computer and use it in GitHub Desktop.
Jupyter Notebook on AWS (amazon EC2) server. Script for configuring Jupyter notebook in server mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| CERTIFICATE_DIR="/home/ubuntu/certificate" | |
| JUPYTER_CONFIG_DIR="/home/ubuntu/.jupyter" | |
| if [ ! -d "$CERTIFICATE_DIR" ]; then | |
| mkdir $CERTIFICATE_DIR | |
| openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "$CERTIFICATE_DIR/mykey.key" -out "$CERTIFICATE_DIR/mycert.pem" -batch | |
| chown -R ubuntu $CERTIFICATE_DIR | |
| fi | |
| if [ ! -f "$JUPYTER_CONFIG_DIR/jupyter_notebook_config.py" ]; then | |
| # generate default config file | |
| #jupyter notebook --generate-config | |
| mkdir $JUPYTER_CONFIG_DIR | |
| # append notebook server settings | |
| cat <<EOF >> "$JUPYTER_CONFIG_DIR/jupyter_notebook_config.py" | |
| # Set options for certfile, ip, password, and toggle off browser auto-opening | |
| c.NotebookApp.certfile = u'$CERTIFICATE_DIR/mycert.pem' | |
| c.NotebookApp.keyfile = u'$CERTIFICATE_DIR/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 = 8888 | |
| EOF | |
| chown -R ubuntu $JUPYTER_CONFIG_DIR | |
| fi | |
| # chmod +x jupyter_userdata.sh | |
| # ./jupyter_userdata.sh |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sha1:bcd259ccf... should be replaced with your pass hash
from notebook.auth import passwd
passwd()