Home » How to Create EC2 Instances and Access

How to Create EC2 Instances and Access

Banner 1

One of the most well-known cloud computing platforms offered by Amazon Web Services (AWS) is Amazon Elastic Compute Cloud (EC2). With EC2, you may start cloud-based virtual servers, or instances, that you can set up and control for a range of uses. We will walk you through the process of setup EC2 instance and accessing an EC2 instance in this blog article.

What is Elastic Compute EC2?

A scalable computing service, Amazon EC2 enables customers to run virtual machines (VMs), also known as instances, in the cloud. The CPU, memory, and storage of EC2 instances can be altered to suit specific needs. Depending on your needs, you can start instances of various operating systems, including Windows, Linux, and others.

Create EC2 Instance

  1. Go to AWS Console Management account
    • To setup EC2 instances, you will need an AWS account. If you don’t have one, go to AWS official website and sign up.
    • Once you have an account:

    2. Launch an EC2 Instance

        • Go to EC2 Dashboard:
          • From the AWS Management Console, find and click on EC2 under the “Compute” section to open the EC2 Dashboard.
        • Click Launch Instance:
          • Click the Launch Instance button to start the process of create EC2 instance.
          • Name your server: My-Demo-Server
        • Choose an Amazon Machine Image (AMI):
          • Amazon provides several pre-configured AMIs that you can choose from based on your use case.
          • For example, you can select a Ubuntu Server if you need a Linux-based system or Windows Server for a Windows-based system. In this Post I select Amazon Linux.
          • Click Select on the AMI you prefer
        • Choose an Instance Type
          • Here, you select the hardware configuration for your EC2 instance (e.g., CPU, RAM).
          • AWS offers various instance types such as t2.micro, t3.medium, etc. For general usage, you can select the t2.micro instance, which is eligible for the free tier if you are a new user.
        • Key Pair
          • You will be prompted to select a Key Pair for SSH access (we will cover this in the next step).
          • Choose “Create a new key pair,” name it, and download the private key file (.pem). Keep this file safe, as you’ll need it to access your instance.
        • Network Setting
          • In this section, you can configure additional settings like the network settings, and security groups. For now, the default settings should work well.
        • Configure Security Group
          • This step is important as it involves configuring the firewall for your EC2 instance.
          • Create a new security group or select an existing one. A typical security group for web applications would allow SSH (port 22) for Linux instances or RDP (port 3389) for Windows instances and Http (80) and TPS (443) for internet access and select source type anywhere.
          • Make sure to allow inbound SSH access if you want to connect to your instance via terminal.
        • Add Storage
          • By default, a root volume (EBS) is created. You can increase the size if needed, but the default size is typically sufficient for most users.
        • Add Tags (Optional)
          • Tags help you identify and organize your resources in AWS.
          • You can add a tag like Name: MyEC2Instance for easier management.
        • Review and Launch
          • Review all your selections and click Launch.

        3. Accessing Your EC2 Instance

        For Linux Instances (via SSH)

        1. Open your terminal (Linux/macOS) or use an SSH client (Windows).
        2. Change Permissions of the Key Pair (for Linux/macOS users):
        3. Run the following command to set the correct permissions for the downloaded .pem file:
        • Find Your Instance’s Public IP Address:
        • Go back to the EC2 dashboard and click on Instances.
        • Select the instance you just launched and find the Public IPv4 address listed.
        • Connect to the Instance:
        • In the terminal, use the following command to connect to your EC2 instance:
        • Replace /path/to/your-key.pem with the path to your key pair file, and your-ec2-public-ip with the public IP address of your EC2 instance.
        • For Ubuntu instances, the default username is usually ubuntu. For Amazon Linux, it’s ec2-user.
        • Accept the SSH Key Fingerprint:
        • The first time you connect to the instance, you will be prompted to confirm the authenticity of the host. Type yes to proceed.
        • You are now connected to your EC2 instance!

        For Windows Instances (via RDP)

        1. Download an RDP Client:
        2. If you are using Windows, the default Remote Desktop Protocol (RDP) client is already installed. For macOS and Linux, you can use a tool like Microsoft Remote Desktop.
        3. Obtain the Administrator Password:
        4. From the EC2 console, select your instance, and click on Connect.
        5. Click the Get Password button and upload your .pem key file to decrypt the password.
        6. Connect Using RDP:
        7. Open the RDP client and enter the Public IP address of the EC2 instance.
        8. When prompted, use the Administrator username and the decrypted password to log in.

        Step 4: Terminate the Instance (Optional)

        If you’re done with the instance and want to avoid unnecessary charges, it’s important to terminate it:

        1. Go to the EC2 dashboard.
        2. Select your instance.
        3. Click on the Actions dropdown and select Instance State > Terminate.

        Conclusion

        Whether you are using Windows or Linux, setup EC2 instance and accessing an instance is simple. You may grow your resources according to your demands with the flexibility that AWS EC2 offers. You may launch an instance, gain access to it, and begin utilizing it for your applications by following these easy steps.

        9 thoughts on “How to Create EC2 Instances and Access

        Leave a Reply

        Your email address will not be published. Required fields are marked *