Skip to content
David Salek edited this page Feb 3, 2018 · 1 revision

Adding rules to AWS Security Group

https://docs.aws.amazon.com/cli/latest/userguide/cli-ec2-sg.html https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing


Daemon

https://github.com/jupyterhub/jupyterhub/wiki/Run-jupyterhub-as-a-system-service http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html https://gist.github.com/shawnrice/11076762 http://supervisord.org/


Jupyter

This section explains how to setup Jupyter under the ec2-user account. In the end, this is not a necessary component of the final solution. For security reasons, JupyterHub will be used instead to give limited access for analyzing data to user plant_monitor (see the next section). For completeness, the Jupyter installation is described below, inspired by the instructions given in these links.

Generate SSL certificates.

mkdir certs
cd certs
sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem

Choose a password and generate an SHA hashed version. It will be used in the further configuration.

ipython
from IPython.lib import passwd
passwd()

Generate Jupyter configuration file.

jupyter notebook --generate-config

Add the following lines to ~/.jupyter/jupyter_notebook_config.py and specify the SHA hashed password. You can directly use the file from this repository You can directly copy the file from this repository https://github.com/salekd/plant_monitor/blob/master/config/jupyter_notebook_config.py

c.NotebookApp.certfile = '/home/ec2-user/certs/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.keyfile = '/home/ec2-user/certs/mykey.key'
c.NotebookApp.open_browser = False
c.NotebookApp.password = 'sha1:...'
c.NotebookApp.port = 8888

Create a new directory for Jupyter notebooks and start Jupyter.

mkdir notebooks
cd notebooks
jupyter notebook

Jupyter can be accessed on port 8888.

https://ec2-34-243-27-176.eu-west-1.compute.amazonaws.com:8888

Alternatively, a ssh tunnel can be created on your local machine

ssh -i .ssh/my_first_EC2_key.pem -L 8157:127.0.0.1:8888 ec2-user@ec2-34-243-177-120.eu-west-1.compute.amazonaws.com

and Jupyter will be accessible under localhost.

http://127.0.0.1:8157

Clone this wiki locally