Test Connection
Checking Connection
ℹ️ Note: There are several ways to connect to EC2 instances. You can follow the instructions to connect to EC2 using PuTTY. In this lab, we will use MobaXterm to establish the connection.
-
Download MobaXterm
-
Access the EC2 Page
- Go to the EC2 page.
- Select Instances.
- Choose the EC2 Public instance.
- Select Details.
- Locate the Public IPv4 address.
-
Using MobaXterm
- After downloading MobaXterm, extract and open it.
- Select Session.
-
Configuring Session Settings
- In the Session settings interface, choose SSH.
-
Session Settings Continued
- In the Session settings interface:
- Enter the Remote host (Public IPv4 address).
- Specify the username as
ec2-user
.
- Choose the Use private key option and provide the path to the
aws-keypair.pem
file created and downloaded during EC2 instance creation.
-
Successful Connection
-
Testing Internet Connection of EC2 Public
Execute the following command to test the internet connection of the EC2 Public instance
ping amazon.com -c5
- Make a ping to EC2 private
ping <IP Private EC2 Private>
Connect to the EC2 Private Server and Check Internet Connection
-
Access to EC2
- Select Instances
- Select EC2 Private
- Select Details
- Select Private IPv4 addresses
- Then connect SSH to EC2 Public
- Perform a ping test to the EC2 Private’s private IP address to test the connection from the EC2 Public server to the EC2 Private server. Use the following command:
ping 10.10.4.105 -c5
-
EC2 Private will not have a public IP address because we are not assigning this server a public IP. To be able to ssh into EC2 Private, we will make an ssh connection from EC2 Public through EC2 Private private IP address
- Download the pscp tool to the same folder containing the aws-keypair.ppk file to copy the aws-keypair.pem file from our computer to EC2 Public .
-
We use puttygen.exe to generate key
-
Select aws-keypair.pem
- Select OK
- Select Save private key with the name aws-keypair.ppk
- Complete the generation key
-
Launch Command Prompt. Change the path to the folder you just downloaded pscp. Run the command below to upload the aws-keypair.pem file to the /home/ec2-user/ directory of the EC2 Public server.
- You will need to replace the public IP address of EC2 Public parameter before running the command.
pscp -i aws-keypair.ppk aws-keypair.pem ec2-user@<EC2 PUBLIC public IP address>:/home/ec2-user/
-
Access to EC2
- Select Instances
- Select EC2 Public
- Select Details
- View Public IPv4 address
- Return to the EC2 connection interface. Make sure you copy the aws-keypair.pem file to the EC2 Public server, we execute the command
ls
- Update the permissions for the aws-keypair.pem file by running the chmod 400 aws-keypair.pem command. AWS requires the key pair file to be restricted before it can be used to connect to the EC2 server.
chmod 400 aws-keypair.pem
- SSH to EC2 Private server
ssh -i aws-keypair.pem ec2-user@<EC2 Private server's private IP address>
- Perform ping test to amazon.com. As you can see, we cannot connect internet from EC2 Private. In the next step, we will create NAT Gateway to allow the EC2 Private server to connect to the internet in the outbound direction. Keep the connection to EC2 Private so that we can check the connection to internet after finishing creating and configuring NAT Gateway.
ping amazon.com