Amazon Web Services - AWS EC2 - Ubuntu 14.04

Setup Environment - Step By Step

Step by step guide

1. PEM file download from AWS console

Login to AWS console from http://aws.amazon.com/

Create new EC2  instance and download pem file: aws_miko.pem and put it into ~/.ssh/ directory.

$ chmod 400 aws_miko.pem

 

Assign new IP address:

AWS Console > EC2 Management > Elastic IPs > Allocate New address ... > Associate Address to EC2 Insatnce

 

Enable all traffic:

Security Groups > set inbound and outbound rules to All traffic

 

 

2. Login to console:

$ ssh -i ~/.ssh/aws_miko.pem ubuntu@52.24.179.158      -Ubuntu 14.04

$ ssh -i ~/.ssh/aws_miko.pem ec2-user@52.24.179.158      -CentOS 6.6

 

 

3. Change passwords after SSH login

$ sudo passwd root

$ sudo passwd ubuntu

 

 

4. Add new user (not sudoer)

# groupadd miko

# useradd -g miko -d /home/miko -s /bin/bash -m miko           

 

//option -m create home dir

# mkdir /homemiko

# chown miko:miko /homemiko

 

5. Create project dirs

//create directory with project files

# mkdir /homemiko

# chown miko:miko /homemiko

# su miko

$ cd /homemiko

$ mkdir com_i-oglasi

$ mkdir com_ioglasi/logs

$ mkdir com_i-oglasi/www

$ mkdir com_i-oglasi/www/public_html      -here we will git clone the project

 

6. Cloning project

# apt-get install git

$ su miko

 

// create public key

$ cd /home/miko/.ssh

$ ssh-keygen -t rsa -C "miko@aws"

$ cat id_rsa.pub  --> Copy this pub. key into Bitbucket

 

 

$ cd /homemiko/com_i-oglasi/www/pub*

$ git clone git@bitbucket.org:smikod/i-oglasi.git

 

 

Notice:

Default user is ubuntu and has sudo privilegies.

$ cat /etc/sudoers

# Allow members of group sudo to execute any command
%sudo    ALL=(ALL:ALL) ALL

 

$ cat /etc/passwd    //list all users

ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash        //has group 1000

 

$cat /etc/group        //list all groups

ubuntu:x:1000:

sudo:x:27:ubuntu     //ubuntu user is in sudo group what means, ubuntu is sudoer and can execute any command as defined in /etc/sudoers