Posts Tagged ‘ec2’

Create user for ssh access to aws ec2 instance

September 28th, 2015 No comments

Creating a user in an amazon ec2 instance in my case ubuntu:

sudo adduser <new_user>
# Next step gives access level
sudo adduser <new_user> sudo 

Create the folder .ssh for the user just created:

cd /home/<new_user>
mkdir .ssh

On your local computer:

    • Generate a key using strong encription:
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -C "optional comment about key"
    • Then check that .ssh directory and the files have right permissions:
chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
    • Next, upload the public key to your server:
cat ~/.ssh/ | ssh ubuntu@<public_ip> 'cat - >> ~/.ssh/authorized_keys'

In the remote server:

    • Copy the authorized_keys from the ubuntu user to the newly created .ssh folder of the new user.
cp ~/.ssh/authorized_keys /home/<new_user>/.ssh/
    • Change the owner of the folder and files to the user newly created:
sudo chown <new_user>:<new_user> /home/<new_user>/.ssh/
sudo chown <new_user>:<new_user> /home/<new_user>/.ssh/authorized_keys
    • Finally login as the user you just created and ensure that the .ssh folder and authorized_keys have the right permissions.
chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh/

At this point you should be able to login using the default amazon key to both users. But in order to login from your computer with the key and the you just created, it is necessary to remove the from your local .ssh/ folder.
In the authorized_keys from the you would need to remove the first entry so the can not login using the amazon default initial key.

Categories: aws, ec2 Tags: , ,

Pointing godaddy domain to an aws ec2 instance

May 3rd, 2014 13 comments

You just bought a domain and don’t know how to point it to your server, just follow these easy steps to make it possible:

First we need to set up AWS to provide an IP address for your DNS settings.

  1. On EC2 Management console you will have a vertical menu on the left hand side.
  2. Under “NETWORK & SECURITY” group click on “Elastic IPs”.
  3. On the top menu you will see a blue button “Allocate New Address” click on it.
  4. Just be sure “EIP used in” is set to “EC2” then click “Yes, Allocate”.
  5. A new IP address will be created on the table, select it by clicking on the empty square by the left of the name.
  6. Now click on “Associate Address” on the pop-up click on instance and select the instance you would like to associate to this IP.
  7. Finally click “Associate” and that’s it. For now to access via SSH, FTP, etc. you will need to use the new elastic IP.

On the godaddy side we will set up the points to address with the new elastic ip.

  1. Login into your godaddy account.
  2. Under the upper menu click “Domains” and then click “Manage my Domains”.
  3. Select the domain you would like to change by clicking the link to the domain on the table under “Domain Name” column.
  4. In Domain Details there are three tabs, you should click on “DNS Zone File”.
  5. Under A(Host) , click on “Edit Record” at the end in “Actions” column.
  6. Now change the value on the field “Points to” with the elastic ip of your amazon ec2 instance.
Categories: aws, domain, ec2 Tags: , , ,