Test Connection
Checking connection
- Download MobaXterm

-
Go to the EC2 page
- Select Instances
- Select EC2 Public
- Select Details
- View Public IPv4 address

-
After downloading MobaXterm, extract and open

-
In the Session settings interface

-
In the Session settings interface
- Remote host, enter
Public IPv4 address
- Specify username, enter
ec2-user
- Use private key, choose the path of aws-keypair.pem created and download at EC2 creation.

- Connection successful.

- Check the connection to the internet of EC2 Public, we execute the command:
ping amazon.com -c5

- Make a ping to EC2 private
ping <IP Private EC2 Private>

Connect to the EC2 Private server and check the internet connection.
-
Access to EC2
- Select Instances
- Select EC2 Private
- Select Details
- Select Private IPv4 addresses
- Then connect SSH to EC2 Public

- Do a ping <EC2 Private’s private IP address> to test the connection from the EC2 Public server to the EC2 Private server. We test the connection between two EC2 instances with the 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
