How to get a free online linux box on Amazon Web Services (AWS)
I'm going to explain how to use the Amazon Web Services Free Tier (http://aws.amazon.com/free/) to setup an instance (Linux machine) and a web server on top of it.
First of all you need an Amazon Web Services (AWS) account, get it at http://aws.amazon.com.
Once you have an account you must enable EC2
By entering your credit card information and a phone number for validation purposes (Your credit card will only be charged if you consume services out of the free tier).
On the AWS Management Console go to EC2 and from the Navigation Menu (left side of the screen) click on Instances
Now click on Launch Instance
Make sure you Select 'Launch Classic Wizard' and Click Continue.
This step is important! on Step 1 of the wizard go to 'Community AMIs', Filter results by 'EBS Images' and Type 'ubuntu-lucid' as shown in the image below.
Using Ubuntu will keep things free.
Select the AMI that fits your needs, I choose Ubuntu lucid 10.4 amd64.
And Click Continue.
This is another important step!
Make sure your Instance Type is Micro (Micro is part of the free tier) and Click Continue
Click Continue again until you get a step called 'CREATE KEY PAIR'. If you already have a Key Pair use that, if not then create a new key pair and download the key file to your system. Click Continue
At the 'CONFIGURE FIREWALL' take the default Security Group and Click Continue.
Finally Click Launch at the 'REVIEW' step of the wizard.
Wait a few minutes and your instance should be up and running (see the image below).
Now you need to assign an IP Address to your instance, click on "Elastic IPs" in the Navigation menu at the left of the screen.
Click on "Allocate New Address" and select EC2 on the popup window and clock Yes.
IMPORTANT! Non-Associated IP Addresses have a cost $$$. Make sure you always have your Elastic IP associated to an instance at all times.
Right-click on your recently created IP Address and Click 'Associate'
Select your instance in the "Associate Address" window and Click "Yes, Associate".
That's it you have an online instance with an IP Address associated to it!
I'll make another post later today with instructions on how to log in, using SSH, to your newly created instance (ubuntu linux in my case).
Only 1 instance at any time (running or not).
Only 1 IP at any time, and such IP must be always attached/associated to an instance (unattached IPs cost you money!).
Always use public/ebs AMIs. If you want Red Hat, Amazon Linux, SuSE, you will have to pay for those OSes.
Update: I did that post about using PuTTY and SSH to login into your Linux instance, and you can find it here.
Now it is time to create a username for yourself using the command 'useradd'.
To create a username called luis I used the following command
sudo useradd -G adm,admin -m -d /usr/luis luis
-G specifies a list of supplementary groups. In this case adm and admin
-m tells the command to create the user home directory
-d specifies the user home directory (to be created as specified by -m), in this case I want the home directory to be /usr/luis
ubuntu@domU:~$ sudo useradd -G adm,admin -m -d /home/luis luis
ubuntu@domU:~$ ls /usr/
bin games include lib lib64 local luis sbin share src
Now set a password to that user you just created using 'sudo passwd <username>'
ubuntu@domU:~$ sudo passwd luis
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
It is recommended that you do not login as root, you should create an account (as you just saw) and use that account to do sudo whenever you need it.
And for security reasons disable ssh root login, or someone could try to brute force your root password and login as root!
Edit the file /etc/ssh/sshd_config:
sudo vi /etc/ssh/sshd_config
Also don't forget to check Password Authentication is enabled
PasswordAuthentication yes
Now restart the ssh service
ubuntu@domU:~$ sudo /etc/init.d/ssh restart
* Restarting OpenBSD Secure Shell server sshd [ OK ]
That's it! Now you can open a ssh connection to your linux box and login using your new credentials!