AWS EC2: Start a Jupyter (IPython) Notebook Server

Written by GalarnykMichael | Published 2016/12/23
Tech Story Tags: python | data-science | aws | ipython | tutorial

TLDRvia the TL;DR App

A while ago, I wrote a post, “Setup and use Jupyter Notebook (IPython) Notebooks on AWS”. While that approach benefits from being easy to setup, but requires you to have key to access. This approach allows for multiple people to access the server with just a password. With that, here let’s just started.

If you get lost, I recommend opening the video in a separate tab.

  1. Install Anaconda. If you don’t have it installed alreday, please see AWS EC2: Install Anaconda on Linux Instance.
  2. ssh to your EC2 instance. If you don’t know how to do this, please see the tutorial AWS EC2: Connect to Linux Instance using SSH.

ssh -i /path_to_key/my_key.pem user_name@public_dns_name

2a. Type ipython into the terminal. This will open ipython.

2b. The following lines are used for password athentication to the jupyter server we will launch.

from IPython.lib import passwd

passwd()

Out[2] will be different for you. It depends on what you enter for your password.

2c. After you verify your password, Be sure to save the output.

2d. type exit() to exit out of ipython

3. In the terminal, type

jupyter notebook --generate-config

mkdir certs

cd certs

sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

cd ~/.jupyter/

nano jupyter_notebook_config.py

4. Type

c = get_config()

c.IPKernelApp.pylab = 'inline'

c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem'

c.NotebookApp.ip = '*'

c.NotebookApp.open_browser = False

# Your password below will be whatever you copied earlierc.NotebookApp.password = u'sha1:941c93244463:0a28b4a9a472da0dc28e79351660964ab81605ae'

c.NotebookApp.port = 8888

5. Exit out of the .py file and type the following into the terminal

nohup jupyter notebook

6. To access your server, enter

https://ip-address:port/

There is also alternative approach to do roughly the same thing here that I would recommend if you can’t get this to work for you. Please let me know if have any questions either here or on youtube.


Published by HackerNoon on 2016/12/23