🖥️☁️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

  1. Go to AWS Console.
  2. Sign in using your credentials.
  3. Navigate to the EC2 Dashboard.

Step 2: Launch an EC2 Instance

  1. Click on Launch Instance.
  2. Choose an Amazon Machine Image (AMI):
    • For Windows: Select a Windows Server AMI.
    • For Ubuntu: Select an Ubuntu AMI.
  3. Select an Instance Type (e.g., t2.micro for free-tier eligible users).
  4. Configure Instance Details (optional: set IAM roles, user data, networking).
  5. Add Storage (default is 8GB for free-tier users; you can modify it if needed).
  6. Configure Security Group:
    • For Windows, allow RDP (port 3389).
    • For Ubuntu, allow SSH (port 22).
    • Restrict access to your IP only for better security.
  7. Review and Launch the instance.
  8. Create a new Key Pair (or use an existing one) and choose .ppk format instead of .pem.
  9. Click Launch Instances.

Step 3: Connect to Your EC2 Instance from a Local Terminal

For Linux/macOS Users:

  1. Open a terminal.
  2. Navigate to the directory where your .ppk file is stored.
  3. Convert .ppk to .pem if needed:
    puttygen your-key.ppk -O private-openssh -o your-key.pem
    chmod 400 your-key.pem
    
  4. 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.

For Windows Users (Using PuTTY):

PuTTY is an SSH client used to connect to EC2 instances on Windows.

  1. Download and Install PuTTY and PuTTYgen from PuTTY official website.
  2. Use .ppk key while creating an instance to avoid conversion.
  3. 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):

  1. Install PuTTY tools:
    sudo apt update && sudo apt install putty
    
  2. 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

  1. Retrieve the Administrator password from the EC2 Dashboard (requires the .ppk key to decrypt).
  2. Open Remote Desktop Connection (RDP) on Windows.
  3. Enter the Public IP of your Windows EC2 instance.
  4. Use Administrator as the username and enter the retrieved password.
  5. 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

Popular posts from this blog

🔥Apache Spark Architecture with RDD & DAG

🌐Filtering and Copying Files Dynamically in Azure Data Factory (ADF)

🌐End-to-End ETL Pipeline: MS SQL to MS SQL Using Azure Databricks