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 Visual Studio Code to establish the connection.
Download Visual Studio Code
Access the EC2 page
In the Connect section
In the Visual Studio Code interface
In the Visual Studio Code search bar
Configure SSH.
Connect via SSH.
Test the internet connection of EC2 Public by running the command:
ping amazon.com -c5
Access to EC2
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 <IP Private EC2 Private> -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
You download an RSA and DSA key generation utility as puttygen.exe
You download an SCP client, i.e. command-line secure file copy is pscp.exe
We use puttygen.exe to generate key
Select aws-keypair.pem
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.
pscp -i aws-keypair.ppk aws-keypair.pem ec2-user@<EC2 PUBLIC public IP address>:/home/ec2-user/
Access to EC2
ls
chmod 400 aws-keypair.pem
ssh -i aws-keypair.pem ec2-user@<EC2 Private server's private IP address>
ping amazon.com