Sitemap
Devante Fields

Devante Fields

Let’s SSH

--

Press enter or click to view image in full size

Overview

In this project I will demonstrate how to create an EC2 Instance in AWS. After creating the EC2 Instance I will then navigate through the terminal and show how to SSH into the EC2 instance. Lastly I will run the “whoami” command to verify that I have moved into the EC2 instance.

Step 1: Create EC2 Instance

Locate the Launch Instance button from the EC2 Dashboard page

Press enter or click to view image in full size

Once you click the Launch Instance button you will then be brought to the next page where you will begin creating your EC2 Instance.

The first thing you will do is name your instance

Press enter or click to view image in full size

Next you will select your distribution

Press enter or click to view image in full size

The next step is to create a key pair. In order to SSH you must have a key pair.

Press enter or click to view image in full size

After creating the key pair it will automatically download onto your computer. You want to make sure you know what folder your downloads go to as you will need this information later in the process.

The next step in creating your instance is to create a Security Group

Press enter or click to view image in full size

The security group will need to Allow SSH traffic from Anywhere.

Leave all other settings as default

You are now ready to Launch Instance!

Step 2: Prepare The Terminal

You are almost there!

Your EC2 Instance is running and you can now begin the process of entering your instance by SSH through the terminal

First step is easy. Open the terminal!

Press enter or click to view image in full size

Remember the folder where your Key Pair was downloaded?

Great!

Get Devante Fields’s stories in your inbox

Join Medium for free to get updates from this writer.

From the terminal navigate to the folder

Press enter or click to view image in full size

Once you’re in the terminal you should run the command pwd. This command will show you what directory you are in.

Once you know what directory you’re in then you run the command ls. The ls command lists all the items in that directory.

I know that the Key Pair I created is in a folder on my Desktop. Now I need to go to the Desktop directory so I run the command cd Desktop to navigate to the correct directory.

Now that I’m in the correct directory I run the command ls in order to see all the items that are in the directory. I know that the folder I’m looking for is titled LUIT so now I run the command cd LUIT to move into that folder.

Once I know I’m in the correct folder I run the command ls one more time to verify that the Key Pair is where it should be.

Now I am in the correct location in the terminal.

Step 3: Connect to Your Instance

The next step is to navigate back to the EC2 Dashboard and select Connect

Press enter or click to view image in full size

There are two commands you are going to copy from the next page and place them into the terminal.

Press enter or click to view image in full size

The first command is to ensure your key is not publicly viewable and that command is

chmod 400 “project_ssh.pem”the second command is 

The second command is

ssh -i "project_ssh.pem" ec2-user@ec2-3-134-88-42.us-east-2.compute.amazonaws.comssh -i "project_ssh.pem" ec2-user@ec2-3-134-88-42.us-east-2.compute.amazonaws.com

After running the first command the terminal should go to the next line ready for another command. That is how you know it was run properly.

Then you run the second command. Press enter.

Press enter or click to view image in full size

The terminal will ask you if you are sure you want to continue connecting. The answer is yes. Press enter.

Now you have successfully entered your instance.

Step 4: Verify You Have Successfully Entered Your Instance

Run the command

whoami
Press enter or click to view image in full size

You will notice after you run the command that the terminal says you are the ec2-user.

You have successfully verified that you have entered into your instance.

--

--