Amazon EC2 How to – Part 2: Login

by Alexander Weiß

In my last post I explained how to set up an instance with Amazon EC2. In this post I’ll show you how you can log into this instance. I’ll focus on Windows as the client OS because it is more complex to setup.

As you probably can remember I chose Ubuntu as the operating system, hence I will use the SSH-protocol to authenticate and login. Therefore I need an SSH-client. If you are a Windows user I can strongly recommend PuTTY. You can download it here. If you are a Linux user you can use the openssh client, it comes preinstalled on most Linux distributions.

Login preparations

Usually the next step is to launch putty and login to your instance. But there are three problems: First, you don’t know which user and password you should use. Second, even if you would know a valid user/password combination you still could not login, because the Ubuntu SSH server is preconfigured to only allow public key authentication. Third, you don’t know which IP address or host name you have to use.

The last problem is easily solved if you take a look at the Amazon EC2 Management Console. You just have to select the instance you want to connect to. After doing so you’ll see that the bottom part of the Management Console displays some information about this instance. Make sure that the “Description” tab is selected and look for the term Public DNS. This is the information you are looking for.

Amazon EC2 How to - Login: host name

Amazon EC2 How to – Login: Public DNS host name

You’ll also see that the instance has a Private DNS and a Private IP. Both have their uses but you can’t use them to login into your instance from your client.

Login key preparations

One of the three problems is already solved: Great job! But there are two remaining. The second is the toughest to solve. You still have the key you downloaded during the setup of the instance, right? You’ll need it now. But you can’t use it with PuTTY, because they are not compatible. You have to convert the key with PuTTYgen. You can download it from the same page as PuTTY. After launching the tool choose “Conversion” -> “Import key” and select the key file you downloaded during the Amazon EC2 instance setup. Now you just have to name the key and give it a password. Click on “Save public key” and store the key in a safe location as you did with the original Amazon key file. You now have a key that is working perfectly fine with PuTTY.

Amazon EC2 How to - Login: key conversion with PuTTYgen

Amazon EC2 How to – Login: key conversion with PuTTYgen

Login username

The last problem you have to solve is the missing username. You could do what you’ll always do when you are looking for an answer and google it. You’ll find the username pretty fast: It’s ubuntu. But google it can’t be the official way, or? Well, every image has a preconfigured user account and the name of this user account is made up by the person who creates the image. For example, if you use an Amazon Linux AMI the default user name is ec2-user.

By the way: you can create your own image and choose your preferred username. I’ll cover this topic in a later post. But for now you have to live with this short explanation.

Now everything is prepared and you can launch PuTTY. You have to configure a few things in PuTTY:

  1. “Session” -> “Host Name”: Enter the Public DNS name
  2. “Connection” -> “Data” -> “Auto-login username”: ubuntu
  3. “Connection” -> “SSH” -> “Auth” -> “Private key file for authentication”: Choose the file you generated with PuTTYgen
  4. Click on “Open”

Now PuTTY should open a shell window and connect to your instance. The last thing you have to do is to enter the password for the key. Now you should be greeted by the command prompt.

Amazon EC2 How to - Login: shell

Amazon EC2 How to – Login: shell login with public key

I hope you enjoyed this post and are curious about the next part of my Amazon EC2 How to. I don’t want to be mean and will give you a hint 😉 : Your instance has only a private IP-address, which is of no use if you want to access it from outside the Amazon cloud. So there must be a way to get a public IP address…

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)