0
0
AWScloud~15 mins

Connecting to EC2 instances in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Connecting to EC2 instances
📖 Scenario: You are setting up a cloud server using Amazon EC2. To manage your server, you need to connect to it securely using SSH. This project will guide you step-by-step to prepare and connect to your EC2 instance.
🎯 Goal: Learn how to prepare your SSH key, configure your EC2 instance's security group, and connect to the instance using the terminal.
📋 What You'll Learn
Create a variable with the EC2 instance's public DNS name
Create a variable with the path to your SSH private key file
Write the SSH command string to connect to the EC2 instance
Add the option to use the SSH key file in the SSH command
💡 Why This Matters
🌍 Real World
Connecting to EC2 instances is a fundamental skill for managing cloud servers securely and remotely.
💼 Career
Cloud engineers and system administrators regularly connect to EC2 instances to deploy, monitor, and maintain applications.
Progress0 / 4 steps
1
Set the EC2 instance public DNS
Create a variable called ec2_public_dns and set it to the exact string "ec2-3-123-45-67.compute-1.amazonaws.com" which represents your EC2 instance's public DNS name.
AWS
Need a hint?

The EC2 public DNS is a string that looks like a web address. Assign it exactly as shown.

2
Set the SSH private key file path
Create a variable called ssh_key_path and set it to the exact string "~/.ssh/my-ec2-key.pem" which is the path to your SSH private key file.
AWS
Need a hint?

The SSH key file path is a string that points to your private key file on your computer.

3
Write the SSH command string
Create a variable called ssh_command and set it to the exact string "ssh ec2-user@" + ec2_public_dns which forms the basic SSH command to connect to your EC2 instance.
AWS
Need a hint?

The SSH command starts with 'ssh ec2-user@' followed by the EC2 public DNS.

4
Add the SSH key option to the command
Update the ssh_command variable to include the SSH key file option by setting it to the exact string "ssh -i " + ssh_key_path + " ec2-user@" + ec2_public_dns so you can connect securely using your private key.
AWS
Need a hint?

The '-i' option tells SSH which private key file to use for authentication.