Run Jupyter Notebook on Amazon-EC2
In this tutorial, i will share to you the quickest way to run ipython notebook using Amazon EC2 (Amazon Elastic Cloud Computing).
Create AWS account: https://aws.amazon.com/ and login to the console
Launch an EC2 instance
Name your EC2 instance as MyFirstInstance
Select an operating system: Ubuntu
Select instance type: t2.micro
Create a key pair: MyFirstInstance.pem and save the key pair in your pc
Highlight the instance and click on Security Groups at the left side of the console:
Click on Actions and Edit inbound rules:
Add rules for Custom TCP, SSH and HTTPS
Your AWS-EC2 instance is ready and the following steps will allow your to connect to this EC2 instance.
Using Putty for windows for SSH (remote shell) and SFTP (transfer files)
Install Putty for windows here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Convert MyFirstInstance.pem into MyFirstInstance.ppk by using puttygen.exe
Double click on puttygen.exe then File -> Load private key (MyFirstInstance.pem) -> Save private key -> use file name MyFirstInstance.ppk
For convenience, save MyFirstInstance.ppk on the same folder where you install Putty
Go back to EC2 console and copy the Public DNS of your instance
Connect to your EC2 instance via SSH to install Anaconda
Open putty.exe and go to Connection-->SSH->Auth
Load the private key (MyFirstInstace.ppk)
Click on Session then input info on host name: <copied from EC2 DNS> then save your session as AWS then click Open
Login as Ubuntu and you are now connected to the EC2 instance. The authentication key (.ppk) allows you to login to EC2 server without a password.
Visit Anaconda and copy link the installer for Linux
https://www.continuum.io/downloads
Download Anaconda to your EC2 server:
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
Install Anaconda
bash Anaconda3-4.2.0-Linux-x86_64.sh
Once Anaconda is installed; create config file for jupyter
cd /home/ubuntu/anaconda3/bin
jupyter notebook --generate-config
cd ~/.jupyter/
vi jupyter_notebook_config.py
add below lines in notebook_config.py
c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False #do not open browser c.NotebookApp.port = 8888 #fix port at 8888
Create a new screen and start jupyter notebook
screen
This will open a new terminal then run the jupyter notebook
jupyter notebook
Now your notebook is running in AWS-EC2
To exit from this screen, Ctrl – a d
To re-open the previous screen type, screen -r
The jupyther notebook is now running in your AWS-EC2 virtual machine and can be accessed from your windows browser
Open firefox or chrome browser and put the ECS DNS and using port 8888
http://<DNS>.us-east-2.compute.amazonaws.com:8888/tree
Set-up a FTP user for ftp (to upload files)
Create a userid in EC2. Sudo allows you to run a command using a super user with proper security privileges
sudo passwd www-data
Set-up the login shell
sudo vim /etc/passwd
Change www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin to /bin/bash
www-data:x:33:33:www-data:/var/www:/bin/bash
Test the connectivity via FTP
Go to your Putty folder and open sftp.exe
Type open www-data@<EC2 DNS> then enter password of www-data
Now you can upload files to your EC2 instance
End of tutorial