Setup an iPython Notebook on AWS with LetsEncrypt Certificate
The first step is to setup an EC2
Ubuntu 16.04 instance that you can ssh into. I won't go into detail here but you should be able to easily google it.
You can get free AWS credit here https://education.github.com/pack
A better guide w/ pictures is here: https://chrisalbon.com/jupyter/run_project_jupyter_on_amazon_ec2.html (Note this doesn't include LetsEncrypt, so it only has self signed certificates)
Once you've setup an instance and ssh'd in, do the following:
sudo su cd ~ wget https://repo.continuum.io/archive/Anaconda3-4.3.1-Linux-x86_64.sh bash Anaconda3-4.3.1-Linux-x86_64.sh . ~/.bashrc
If you have your own domain you can link it so you don't have type in the IP address each time you want to access your notebook.
Install Certbot (if you have your own domain)
sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install certbot
mkdir -p /root/.key certbot certonly --webroot /root/.key -d YOURDOMAIN.com
If you don't have your own domain, create a self signed certificate.
Self Signed Certificate
mkdir -p /root/certs cd /root/certs sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout privkey.pem -out cert.pem
Configure iPython and get Password
cd ~ jupyter notebook --generate-config # Create jupyter config printf "from notebook.auth import passwd\nprint(passwd())" | python
Enter your password and confirm. Copy the result as we'll use it in the next step.
# Set options for certfile, ip, password, and toggle off c.NotebookApp.certfile = u'/root/.key/cert.pem' c.NotebookApp.keyfile = u'/root/.key/privkey.pem' c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.password = u'sha1:bcd259ccf...<put output from above here>' c.NotebookApp.open_browser = False c.NotebookApp.port = 443
Run iPython in background
sudo su jupyter notebook &> /dev/null &
Now you can connect to the url:
If you have a self signed certificate you'll get a warning that your connection is unsafe. Click
advanced and then
You'll then be prompted for the password you set in the
Configure iPython and get Password step. Enter that and click continue.
Now you have an iPython notebook running on AWS!