Connecting To EC2 Instance via SSH

If you are using MAC you can use terminal. If you are using Windows I recommend PUTTY and PUTTYGEN http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

You also need to have your Private Key when you created your instance.

Some other things you should have in front of you:

Bash Commands (command line for linux)

VI editor Commands (file editor in the command line)

File Zilla

Connecting with SSH

Secure Shell (SSH) is how you run commands on the instance. The key pair you created is a security key that allows you to connect. Without the key you can’t connect to the instance.  The instance stores a public key that is sent to you when you try to connect to compare to the private key. If they match then you can access the instance.

WINDOWS: Setup Putty and Connect via SSH

The keyfile you downloaded has a .pem extension by default but putty and filezilla require it to be in a different format (.ppk) but good news: putty transforms it for you. Open puttygen and open the key file. You will have to select ALL files instead of the default ppk in order to find the file. When you open it puttygen will prompt you that you need to save it in the ppk format.  Click save private key to do this. I just name it the same as the pem file as to not confuse myself.  Now that you have a usable file open Putty. On the left tab go down and open the SSH branch under connection. Select the Auth Branch under SSH. Browse for the .ppk file and then go back up to Session

Put your elastic IP in the Host Name/IP box Use port 22 (make sure you opened that port in your security group in amazon aws console. see the first tutorial) and click open. If it connects successfully (which it should) you can enter a name for the connection and save it so you don’t have to repeat all these steps every time.

Once you are connected you will see a terminal screen asking you what user to log in as. you need to use “ec2-user” for this amazon instance.

Mac OSx: Connect via SSH

Open terminal and navigate to the folder where you saved the keygen file. if you don’t have root privileges type sudo before a command. Your command will be

ssh -i nameofyourkeyfile.pem ec2-user@1.2.3.4

use the name of your key file and your elastic ip NOT 1.2.3.4 …

You now have control of your instance. procede with caution if you are not familiar with linux yet.  you can run commands to view files and directories.  you start out in your home directory when you login to the instance so to goto the root you can type

cd ../..

this will back you up 2 directories to the main root.

In the next lesson we will explore the directories you will be using and setting up Apache, Mysql and PHP

Getting Started With Amazon EC2 – Web Server

This article is exactly what it states: A getting started guide for setting up a Web Server in the CLOUD. (gasp) It sounds fancy but the cloud is just a marketing word for the internet.  We will however be learning about Amazon’s Cloud Service known as EC2. You will learn a basic summary of all the basic technologies required to setup a simple LAMP Web server (Linux, Apache, MySQL, PHP).

Why host in the cloud?

To start its cheap. You can setup a micro instance (more on this soon) for free basically. Amazon has different pricing options but at this point their micro instance is basically free for a year. Some of the other services required have some charges but the beauty of hosting in the cloud is that if your application needs or web server needs grow, Amazon EC2 can handle it and gracefully.

OK.. now onto the good stuff!

This article is aimed at someone who has little or no experience with linux (I did not when I embarked on this adventure), a medium level of experience with php mysql and apache.  (You just need to have at least used these to understand everything I will explain). I am not going to explain the entire process in one article. This article will explain a little about some of the technologies and setting up your first instance. Next article will talk about setting up Apache, MySQL, and PHP.

First things first: Register your Amazon AWS account.

http://aws.amazon.com

You can create a new free account in minutes. Have a phone and credit card handy. You have to verify your account with a pin. Amazon calls you and you enter the pin. You also have to enter your credit card info. (Please Please look at the pricing of different services before launching an instance AND finish this article ;) http://aws.amazon.com/free/

Once your account is setup login and go to My Account/Console and select AWS Management Console. You will see a big huge pane of a bunch of acronym technologies. Click EC2.

Click the Launch Instance button to launch your first instance (Instance of a virtual server).

What is an instance?

Basically it is a virtual server only it’s not the same as a virtual server. If you have to restart this server you lose your files… ouch. You can read about data persistence and redundancy on amazon’s site but have no fear; amazon has thought about this.

Elastic Block Store

Previously when you created an instance you had a local filesystem to your instance that held all that instances data and files. When this instance would have to restart (and it will.. eventually) all the data was lost.  EBS was created to eliminate that dependency.  Your EBS storage is persisted outside of your regional server so if you go down you can reboot with your existing data. More details on that in future articles. Just commit to your memory that the instance will use it.

After you click launch instance a wizard pops up. Keep the classic wizard and click continue. We will be setting up Amazon’s 64 bit Linux Instance (free tier noted by gold star). You have thousands of options between community created AMIs and Amazon AMIs but we will set up this default Amazon Linux Server.

Choose 1 instance and type micro (free…) You can choose an availability zone but it doesn’t matter too much. Select continue. Check prevent accidental termination on the next screen and leave everything else the same and continue. You can create a Named Pair. Just call it WebServer or something like that.

Key Pair (!important)

In order to access your instance with ssh terminal (this is how you will tell the server what to do) You need to have a private key on your computer that matches the key on the instance. Save this file and protect it. Name it something simple and download the keypair.

On the next screen you setup a security group. This just simply holds the rules for your instance. For right now lets just leave port 22 open for 0.0.0.0 (default) this is the secure shell port. If it is not setup choose ssh from the select box and add it. then click apply changes. We will come back and explain this in detail and add other rules like HTTP port 80 so we can use this as a web server.

You will be taken to a final screen to view all the options and after you do click launch. When you launch the instance it starts the time on the instance so if you don’t have a free instance this is where you start racking up charges.  It might take a few minutes (or seconds in my case) for the instance to get up and running to take a snack break and come right back.

Now you are ready to assign an IP address to your instance. Elastic IP is free as long as it is attached to an instance. You will be billed for an Elastic IP that is just sitting there not pointing to anything. Allocate a new IP Address and then you Associate it with your instance. Give it a few seconds and you are ready to start setting up the instance. The next article will handle connecting with ssh and setting up Apache MySQL and PHP.

Congrats you are now “IN THE CLOUD”.

 

 

 

 

Introduction

Welcome to my very own personal how did you do that blog.  My goal here is to simply save you some time by posting tutorials that will help you accomplish tasks that I have already learned. My goal is to have a solid network resource for professionals in all industries and fields that know they can rely on the information found here to accomplish their task.  Enjoy!