-
-
Save SuperJohn/aca444ee2e5f3ac854b40c2fd89ce6b0 to your computer and use it in GitHub Desktop.
configure jupyter notebook server (to be passed as user data when you launch an aws ec2 instance)
This file contains 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment