🖥️☁️AWS EC2: A Beginner's Guide to Creating and Connecting an Instance
AWS EC2: A Beginner's Guide to Creating and Connecting an Instance
What is AWS EC2?
Amazon Elastic Compute Cloud (EC2) is a web service that provides secure, resizable compute capacity in the cloud. It allows users to run virtual servers (instances) on demand, eliminating the need for on-premise hardware.
Features of AWS EC2:
- Scalability: Scale instances up or down based on demand.
- Security: Integrated with AWS Identity and Access Management (IAM) and Security Groups.
- Cost-effective: Pay-as-you-go pricing model.
- Multiple instance types: Optimized for various workloads (general-purpose, compute-optimized, memory-optimized, etc.).
- Elastic IPs: Static IPs that can be remapped to different instances.
- Auto Scaling: Automatically adjust capacity to maintain steady performance.
How to Create an EC2 Instance in AWS
Follow these steps to set up an EC2 instance:
Step 1: Log in to AWS Console
- Go to AWS Console.
- Sign in using your credentials.
- Navigate to the EC2 Dashboard.
Step 2: Launch an EC2 Instance
- Click on Launch Instance.
- Choose an Amazon Machine Image (AMI):
- For Windows: Select a Windows Server AMI.
- For Ubuntu: Select an Ubuntu AMI.
- Select an Instance Type (e.g., t2.micro for free-tier eligible users).
- Configure Instance Details (optional: set IAM roles, user data, networking).
- Add Storage (default is 8GB for free-tier users; you can modify it if needed).
- Configure Security Group:
- For Windows, allow RDP (port 3389).
- For Ubuntu, allow SSH (port 22).
- Restrict access to your IP only for better security.
- Review and Launch the instance.
- Create a new Key Pair (or use an existing one) and choose
.ppk
format instead of.pem
. - Click Launch Instances.
Step 3: Connect to Your EC2 Instance from a Local Terminal
For Linux/macOS Users:
- Open a terminal.
- Navigate to the directory where your
.ppk
file is stored. - Convert
.ppk
to.pem
if needed:puttygen your-key.ppk -O private-openssh -o your-key.pem chmod 400 your-key.pem
- Connect to the instance using SSH:
ssh -i your-key.pem ec2-user@your-ec2-public-ip
- Replace
your-key.pem
with your actual key file. - Replace
your-ec2-public-ip
with the public IP of your EC2 instance.
- Replace
For Windows Users (Using PuTTY):
PuTTY is an SSH client used to connect to EC2 instances on Windows.
- Download and Install PuTTY and PuTTYgen from PuTTY official website.
- Use
.ppk
key while creating an instance to avoid conversion. - Connect to EC2 Using PuTTY:
- Open PuTTY.
- In the "Host Name" field, enter
ec2-user@your-ec2-public-ip
. - Under "Connection → SSH → Auth", browse and select the
.ppk
file. - Click Open.
- Log in using the default username (
ec2-user
for Amazon Linux/Ubuntu,Administrator
for Windows).
For Ubuntu Users (Using .ppk
Key Directly):
- Install PuTTY tools:
sudo apt update && sudo apt install putty
- Connect using PuTTY on Ubuntu:
putty -i your-key.ppk ec2-user@your-ec2-public-ip
Step 4: Connect to Windows EC2 Instance Using RDP
- Retrieve the Administrator password from the EC2 Dashboard (requires the
.ppk
key to decrypt). - Open Remote Desktop Connection (RDP) on Windows.
- Enter the Public IP of your Windows EC2 instance.
- Use Administrator as the username and enter the retrieved password.
- Click Connect.
Step 5: Verify Connection
Once connected, you should see the instance’s command-line interface (for Linux) or desktop (for Windows). You can now install packages, configure services, and deploy applications.
Conclusion
AWS EC2 is a powerful service for running cloud-based virtual machines. Setting up an EC2 instance and connecting via SSH or RDP is a fundamental skill for cloud computing. By following the steps above, you can easily launch and manage your EC2 instances securely and efficiently.
Next Steps:
- Set up a web server on your EC2 instance.
- Configure Elastic IP for a static IP address.
- Automate deployments using AWS CLI or Terraform.
Have any questions? Drop a comment below!
Comments
Post a Comment