Amazon Web Services – Connecting to your Linux Instance

We have already launched a free instance of an Amazon AMI in our last post. Now we’ll look at the ways you’ll connect to your Linux instance.  This will be a lengthy post, mainly due to the fact that there will be a lot of “showing” along the way.

Connecting to a Linux AMI – Securely

SSH Key Pairs

In the last post I didn’t go into how to create a key pair.  You’ll need one in order to connect to any instance, so we’ll quickly create one now while we spin up a new Linux instance (just as we did in our last post).  Be sure to select one of the available free instances. For this post we will again use the Amazon AMI. When you select the instance you will be spinning up, you can create a new key pair as shown below.

AWS - Create Key Pair
Creating your Key Pair

All you need to do is name your key pair, and then you’ll be able to download it by clicking the download button.

AWS - Downloading your Key Pair
Filling in your Key Pair information to download your Key Pair.

Remember where you save your file (it will have a “pem” extension).  So in the example above you will download GettingConnectedLinux.pem to your local computer.  Don’t share this file with anyone or post it on the net anywhere.  It’s your security key into your environment.  If you make it public, your environment is now public… so keep it safe. Amazon describes your key pair as follows:

Public AMI instances have no password, and you need a public/private key pair to log in to them. The public key half of this pair is embedded in your instance, allowing you to use the private key to log in securely without a password. After you create your own AMIs, you can choose other mechanisms to securely log in to your new instances.

So now you have a key associated to an instance that you have spun up.  Now we can work on getting connected.

Connecting to your instance

Confirm your instance is up and running.  Navigate to your Instances menu so we can see what instances are running

AWS - Navigate to your instance
Navigate to your instance view

You should now see your running instance.  In our example we called our Amazon AMI “GettingConnectedLinux”.

AWS - Running Instance
Confirm your instance is running

Now right-click on your running instance and you will get a sub menu.  We are looking for “Connect” at the top of that sub menu.

AWS - Get Connected
Getting connected to your Linux instance

You’ll get a new dialog that will open.  We will be connecting from our browser using the Java SSH client.  You can set up your own connection using your own SSH client, but for this example we’ll be using the Java SSH client.

AWS - Connection Dialog
Connection Dialog box for Linux

Here’s where we need that key pair file.  There is no browse option here… you need to type in the exact path & file name of your key pair file.

AWS - Completed Connection Dialog
Completed Connection Dialog.

When the path and file name are complete you can click “Launch SSH Client”.    This will begin the process of connecting to your instance.  You will be prompted to add this host to your known hosts if you like.  It’s not required.  If all goes well, you’ll see a terminal window that is now connected to your instance.

AWS - Connected to your Amazon Instance
Terminal windows indicating successful connection to your instance.

If you know your way around Linux…. you’re all set.  You are connected and able to do whatever you like to this instance.  You can install packages, configure it as a web server, do anything you like to it.  Just remember though, Amazon is tracking the usage.  You get 750 hours a month of free usage if you are using a free tier eligible AMI.  If you get crazy and spin up 2-3 free tier AMI’s you are chewing up an hour of time for each instance.  If you go over the 750 hours you will be charged.  So, while you’re playing, keep it to one running instance at a time.

Cleaning Up

When you are done having fun you’ll want to disconnect from your instance.  If you are completely done with your instance, you may want to permanently terminate it.  To do this, first disconnect from your instance.  Simply select the File menu, then Exit.

AWS - Disconnect from your Instance
Disconnect from your Linux instance.

If you are going to connect again later, you can keep your instance running.  If you want to keep the state of your instance, but don’t want it running any longer, you can stop your instance.  If you are done with this instance and want to permanently delete it, you can terminate it.  To terminate your instance you can right-click on your instance (as we did when we connected to it) and select terminate.

AWS - Terminate your instance
Terminate your AWS instance

Remember, this is a permanent action.  If you have work you want saved, select “Stop”, not “Terminate”.  Once you have you have terminated your instance, you’ll see that reflected in the status of your instance view.

AWS - Terminated Instance
Instance View showing terminated instance

This status will stay in your view for a while, but will eventually be cleared from your dashboard completely.

That’s It!

So now you know how to connect to a Linux free micro instance on Amazon Web Services.  Here’s the thing to keep in mind… these are sandboxes for you.  You can create, destroy, terminate anything you want as many times as you want so you can learn what you want to learn when you want to learn it.  With the micro instances you have 750 hours of free usage per month for one year.  Make the most of that year.  Experiment, create, try, fail, try again… and come out the other side knowing more than you did when you went in.

Best of luck and let me know if you have any questions!

PS – I have already terminated all the instances that have been used in this post.  That’s why I haven’t obscured anything in the images.  You get to see what I saw when I spun them up so you get a feel for what you expect to see… but don’t waste your time trying to hack into any of these instances… they’re gone… long gone.


Enhanced by Zemanta

Amazon Web Services – Getting Started

Hopefully you have already signed up for your Amazon Web Services (AWS) account. It’s simple & straight forward so I won’t be going over that here.

Once you are signed in, you will go to your control panel, shown below.

AWS Full Console
Amazon Web Services console showing all your available AWS options.

Once you can see this screen you are on your way to playing in the cloud.  For this post we will concentrate on EC2 and spinning up an instance.  It’s short & sweet and easy to accomplish. Click on the EC2 link to go into the EC2 console.  It will be from here that we will be launching virtual machines (AWS refers to them as instances).  Clicking on the link will take you to the EC2 specific console.It will take no more than 10 minutes from here to get your first virtual server up and running. As you can see in the screen below, the yellow highlighted area is our starting point.

EC2 Console
EC2 Console

Click on “Launch Instance”.  This will take you to another view that will allow you to choose the type of machine you want to deploy.  You can upload your own virtual machines that can be deployed on EC2, but aren’t covering that in this post.

Selecting your instance (AWS AMI)
Selecting your instance (AWS AMI)

There are 4 items to make note of here:

  1. Naming your instance.  This is actually optional, but a good practice none the less.  Just type in a name that you want to use for your own benefit.
  2. Key Pair.  Since I am assuming this is your first time in, you don’t have a key pair established yet.  You need one in order to later connect to your instance.  So, select “Create New” in order to create your key pair file.  Amazon’s documentation on key pairs can be found here.  In general you want to:
    • Open the Amazon EC2 console
    • Open the Amazon EC2 console at
      Click Key Pairs in the Navigation pane.
    • The console displays a list of key pairs associated with your account.
      Click Create Key Pair.
    • The Key Pair dialog box appears.
      Enter a name for the new key pair in the Key Pair Name field and click Create.
    • You are prompted to download the key file.
      Download the key file and keep it in a safe place. You will need it to access any instances that you launch with this key pair.
  3. Choose the AMI you will be launching.  AMI = Amazon Machine Instance and is how Amazon refers to the virtual machines it provides to its customers. You can choose any AMI you’d like… but I’d stay in the free tier of service by selecting one that is starred & noted as “free tier eligible”.  For this post I’m selecting the Amazon Linux AMI (which I believe is a Debian Linux distribution).  It has a lot of the basics contained within it and it’s easy to add-on to if you want.
  4. Once you have items 1-3 take care of, click “Continue” to start the process of launching your instance (virtual server).

You will be prompted with another screen after clicking “Continue”.

Launching an Amazon AMI
Launching an Amazon AMI

For this post, we’ll just click “Launch” at this point and get the instance running.

AWS Instance starting
AWS Instance starting

You can close this screen.  The instance will spin up quite quickly (if you chose a Windows instance it’ll take longer).  You can now see your instance details by clicking on the left menu, selecting “Instances”.

Selecting your Instance View
Selecting your Instance View


Now there’s plenty more we can do here… but I think that’s plenty for “Getting Started”.  In the next post we’ll connect to the running server and do a few basic checks.  I’ll be running Linux again… so be prepared for a prompt based view.  I may do a separate post on running a Windows instance since you’d use SSH to connect to Linux and RDP to connect to Windows.

Get your free micro instance running and we’ll get connected to it in the next post.  Let me know your thoughts/comments/questions and I’ll do what I can to help you out.

Until next time…



Enhanced by Zemanta

The Linux Command Line

If you really want to know your way around a Linux box, this is the book to get.  It gently exposes you to the environment in very digestible nuggets.  Starting with “What is a Shell” and typing your first simple commands all the way to writing shell scripts utilizing IF statements, CASE statements and Loops, this book will take you as far as you want to go.  It’s written in a conversational style that makes it quick to read & understand.  There’s also some fun geek-related quotes you won’t want to miss…

The Linux Command Line
The Linux Command Line

Have you ever noticed in the movies when the “super hacker”—you know, the guy who can break into the ultra-secure military computer in under 30 seconds—sits down at the computer, he never touches a mouse? It’s because movie makers realize that we, as human beings, instinctively know the only way to really get anything done on a computer is by typing on a keyboard.

For the beginner, you want to take your time with Part 1: Learning the Shell.  It lays a solid foundation for you to work from in later chapters.  Understanding the basics, especially the location of files within the file system itself, will allow you to move through the latter section more easily.  And pay attention to the tips that are presented to you.  I still consider myself a N00b, but I thought I knew precisely what symbolic links were… but I was wrong.  This book taught me a few new things along the way.

For the intermediate or advanced user, you may find all you need online and need not bother with buying a book.  I like consolidated information though (I have enough tabs open in Firefox and Chrome already) and if you’re intermediate and looking to write shell scripts and possibly automate some system maintenance, I think you’ll find this book useful. It’ll give you insights and examples that you can build off of.

Another quote from the author that I like explains it like this:

Most computer users today are familiar with only the graphical user interface (GUI) and have been taught by vendors and pundits that the command line interface (CLI) is a terrifying thing of the past. This is unfortunate, because a good command line interface is a marvelously expressive way of communicating with a computer in much the same way the written word is for human beings. It’s been said that “graphical user interfaces make easy tasks easy, while command line interfaces make difficult tasks possible,” and this is still very true today.

This is true of Windows as much as it is of Linux… so get your hands on the keyboard and enjoy!


Enhanced by Zemanta