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.

  1. Download MobaXterm

    Download MobaXterm

    Create VPC

  2. Access the EC2 Page

    • Go to the EC2 page.
    • Select Instances.
    • Choose the EC2 Public instance.
    • Select Details.
    • Locate the Public IPv4 address.

    Create VPC

  3. Using MobaXterm

    • After downloading MobaXterm, extract and open it.
    • Select Session.

    Create VPC

  4. Configuring Session Settings

    • In the Session settings interface, choose SSH.

    Create VPC

  5. 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.

    Create VPC

  6. Successful Connection

    Create VPC

  7. Testing Internet Connection of EC2 Public

    Execute the following command to test the internet connection of the EC2 Public instance

ping amazon.com -c5

Create VPC

  1. Make a ping to EC2 private
ping <IP Private EC2 Private>

Create VPC

Connect to the EC2 Private Server and Check Internet Connection

  1. Access to EC2

    • Select Instances
    • Select EC2 Private
    • Select Details
    • Select Private IPv4 addresses
    • Then connect SSH to EC2 Public

Create VPC

  1. 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

Create VPC

  1. 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 .

You download an RSA and DSA key generation utility as puttygen.exe

  1. We use puttygen.exe to generate key

    • Select Load

Create VPC

  1. Select aws-keypair.pem

    • Select OK
    • Select Save private key with the name aws-keypair.ppk

Create VPC

  1. Complete the generation key

Create VPC

  1. 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/

Create VPC

  1. Access to EC2

    • Select Instances
    • Select EC2 Public
    • Select Details
    • View Public IPv4 address

Create VPC

  1. 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

Create VPC

  1. 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

Create VPC

  1. SSH to EC2 Private server
ssh -i aws-keypair.pem ec2-user@<EC2 Private server's private IP address>

Create VPC

  1. 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

Create VPC