Skip to content

Instantly share code, notes, and snippets.

@hisplan
Last active November 13, 2021 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hisplan/f079f1a418276b4fc1f56500191e9553 to your computer and use it in GitHub Desktop.
Save hisplan/f079f1a418276b4fc1f56500191e9553 to your computer and use it in GitHub Desktop.
Setting up Jupyter Notebook on AWS

Setting up Jupyter Notebook on AWS

Launch an AWS EC2 instance.

Install Miniconda:

wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.10.3-Linux-x86_64.sh
bash Miniconda3-py38_4.10.3-Linux-x86_64.sh

Log out, log back in.

Create a conda environment called workplace, install Python v3.8, pip, and Jupyter Notebook:

conda create -n workplace python=3.8 pip jupyter

Create a screen:

screen -S notebook

Activate the workplace environment:

conda activate workplace

Create a SSL certificate:

mkdir ~/ssl && cd $_
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "cert.key" -out "cert.pem" -batch

Generate a default Jupyter config file:

cd ~
jupyter notebook --generate-config

Create a password for Jupyter Notebook access:

jupyter notebook password

Launch Jupyter Notebook:

jupyter notebook --no-browser --port 8888 --ip 0.0.0.0 --certfile ~/ssl/cert.pem --keyfile ~/ssl/cert.key

CTRL + a + d to detach from the screen.

Run the following to get the notebook URL and visit the URL from your local browser:

echo "https://`curl -s http://169.254.169.254/latest/meta-data/public-hostname`:8888"

Ignore the warning and proceed. Enter your password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment