This is tutorial on running Project Jupyter Notebook on an Amazon EC2 instance. It is based on a tutorial by Piyush Agarwal which did not work for me immediately, but I tweaked a few things and got it working.
Note: This is not a beginner's tutorial. I don't explain some of the steps fully and don't explain some concepts. There are other tutorials out there for that.
Create an AWS account
An EC2 instance requires an AWS account. You can make an account here.
Navigate to EC2
Log into AWS and go to the EC2 main page. Then you will see a 'Launch Instance' button.
Launch a new instance
Check out your new instance
Create a new security group
Create and download a new key pair
View connect instructions
Set permissions on key pair
chmod 400 tutorial.pem
Connect using ssh
ssh -i "tutorial.pem" [email protected]
Are you sure you want to continue connecting (yes/no)?
Download Anaconda to instance
Visit Anaconda's download page and right click to get the url of the latest version of the Linux 64-bit version. In my case this url was:
Now, back in the terminal, tell the EC2 instance to download that file. Note: You aren't downloading the file to your computer, you are downloading it to the EC2 instance and installing it from there.
Press enter a few times
Type 'yes' to agree
'Press ENTER to confirm the location'
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /home/ubuntu/.bashrc ? [yes|no]
[no] >>> yes
Set Anaconda as the preferred environment
[[email protected]:~$ which python
Create a password for jupyter notebook
from IPython.lib import passwd
Create config profile
jupyter notebook --generate-config
Create certificates for https
sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
c = get_config() # Kernel config c.IPKernelApp.pylab = 'inline' # if you want plotting support always in your notebook # Notebook config c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem' #location of your certificate file c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False #so that the ipython notebook does not opens up a browser by default c.NotebookApp.password = u'sha1:98ff0e580111:12798c72623a6eecd54b51c006b1050f0ac1a62d' #the encrypted password we generated above # It is a good idea to put it on a known, fixed port c.NotebookApp.port = 8888
Remember to replace
sha1:98ff0e580111:12798c72623a6eecd54b51c006b1050f0ac1a62d with your password!
Create folder for notebooks
Create new screen
Start Jupyter notebook
Detach from screen
Ctrl-a and then
Other useful commands:
- Create new window:
- Switch windows:
- Reattach to Screen:
Visit Jupyter notebook in browser
Your EC2 instance will have a long url, like this:
Visit that URL in your browser: