Connect to AWS EC2 Instance via Putty/SSH

For connecting to your AWS EC2 instance, you can do it via Putty (for Windows user) or via SSH (for Linux/Mac user).

Assuming that you have created an AWS EC2 Instance and Key Pair (.pem file) is locally available for connection. If not then you can follow our below posts to complete these prerequisites.

First, find your EC2 instance Public DNS

Connect to AWS EC2 Instance via SSH_1

For Windows Users

Step1: Download Putty and putty gen from here

Step 2: Use putty gen to convert .PEM file to .PPK file. See Blog: How to convert .PEM file to .PPK file using putty gen

Step 3: Launch Putty and enter the host IP address and set the port to 22.

Connect to AWS EC2 Instance via SSH_2

Step 4: Navigate to Connection/SSH/Auth. Click “Browse” and select the .PPK file you exported from putty gen.

Connect to AWS EC2 Instance via SSH_3

For Mac/Linux users

Step 1: Use the chmod command to make sure your private key file isn’t publicly viewable. For example, if the name of your private key file is my-key-pair.pem, use the following command:

Step 2: Use the ssh command to connect to the instance. You’ll specify the private key (.pem) file and user_name@public_dns_name.
Example:- For Ubuntu, the username is ubuntu. For Fedora, the user name is either fedora or ec2-user.

You’ll see a response like the following.

Step 3: Enter yes and You’ll see a response like the following.

 

Install OpenJDK 8 on Ubuntu 14.04 LTS

Step 1: Add the OpenJDK Team Personal Package Archive (PPA)

Add the PPA:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu1

Step 2: The Installation

The best practice is first to update our packages

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu2

Then install Open JDK 8 with the PPA installer:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu3

Step 3: Verify Installation

Now verify that Java is installed by typing:

You will see result similar to:

Once, we run the above command you should be able to see the below message on the command interface.

Install OpenJDK 8 on Ubuntu4

Create a new Instance (Ubuntu 14.04) on AWS EC2 and setup Security Groups

To create a new Instance (Ubuntu 14.04) on AWS EC2 and setup Security Groups is a very simple task and will take approx 5-10 minutes to complete. In this post, we will see how we can create a new Instance (Ubuntu 14.04) on AWS EC2.

Step 1: First login to your AWS console, select any region and click on EC2 link.

Create a new Instance (Ubuntu 14.04) on AWS EC2 1

Step 2: You will see the EC2 Dashboard screen. Now click on Launch Instance button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 2

Step 3: Choose any Amazon Machine Image (AMI) which basically means the instance type you want to launch. In this post I have selected  “Ubuntu Server 14.04 LTS (HVM), SSD Volume Type” but you can select any Instance which you want to launch.

Create a new Instance (Ubuntu 14.04) on AWS EC2 3

Step 4: Next step is to choose an Instance type. In this post I have selected “t2.micro” you can select any Instance type as per your requirement and then click Next:Configure Instance Details button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 4

Step 5: Configure Instance Details and click on Next: Add Storage button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 5

Step 6: Configure Add Storage and then click on Next: Tag Instance button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 6

Step 7: Tag Instance ( A tag consists of a case-sensitive key-value pair. For example, you could define a tag with key = Name and value = Webserver.) and click Next: Configure Security Group button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 7

Step 8: Configure Security Group

A security group is a set of firewall rules that control the traffic for your instance. On this page, you can add rules to allow specific traffic to reach your instance.
For example, if you want to set up a web server and allow Internet traffic to reach your instance, add rules that allow unrestricted access to the HTTP and HTTPS ports.

So, I have added rule HTTP:80 and HTTPS:443. But you can configure Security Group according to your need and click on Review and Launch button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 8

Step 9: Next step is to review your Instance details and then click on the Launch button.

Create a new Instance (Ubuntu 14.04) on AWS EC2 9

Step 10: Select an existing key pair or create a new key pair.

A key pair consists of a public key that AWS stores, and a private key file that you store. Together, they allow you to connect to your instance securely. For Windows AMIs, the private key file is required to obtain the password used to log into your instance. For Linux AMIs, the private key file allows you to securely SSH into your instance.

If you don’t have any key pairs. Please create a new key pair by selecting the Create a new key pair option above to continue.

Then you have to download the private key file (*.pem file) before you can continue. Store it in a secure and accessible location. You will not be able to download the file again after the instance has been created so please be careful and remember to download the same.

Create a new Instance (Ubuntu 14.04) on AWS EC2 10

After downloading the *.pem file click on Launch Instance button and wait for the instance to launch then you will see the below “Launch Status” screen that means your instance has been created successfully.

Create a new Instance (Ubuntu 14.04) on AWS EC2 11