Ubuntu in EC2
We'll dive into setting up and running Ubuntu on Amazon EC2, one of the most powerful and flexible cloud computing platforms. Whether you're a beginner exploring cloud services or a seasoned developer looking to streamline your deployments, this guide will walk you through the process of launching an EC2 instance, configuring Ubuntu, and optimizing it for your specific needs. By the end, you’ll have a solid foundation to leverage Ubuntu’s robust capabilities in a scalable and secure AWS environment.
Prerequisites
To Deploy your application, you need a AWS account to use EC2 (Elastic Computing Cloud) instance which you can be used in AWS free tier.
Lets Start Creating
After login process, search for EC2 in the search box.
So now, You can see a lot in the dashboard. First, lets create a key pair,
After creating your key, you can see your key in the key pairs list.
After creating your key, now we can create our first AWS EC2 instance, Now get back to your EC2 Dashboard and click Launch instance.
Preferred setting for Launch an instance:
Name: [Your wish]
Application and OS Images: [Ubuntu]
Instance Type: [Default:t2.micro]
Key pair: [Selected what u have created before]
Network settings:
Configure storage: [Default]
After all these setting Launch the instance
After Succesfulling launching the instance, get back to instance and you can see your instance running.
Copy the public IPv4 address, open the terminal where the .pem file downloaded (which is downloaded while creating a key pair).
If you keep getting a permission denied error, you can debug it by typing
sudo chmod 400 Downloads/LAMP.pem (This is for Windows)
chmod g-r,o-r -/Downloads/LAMP.pem (This if for Mac)
or ensuring that inbound SSH traffic is allowed from your IP address and updating the security group rules to allow SSH access on AWS through these steps:
Open the AWS Management Console and navigate to the EC2 service.
Select the appropriate region from the top-right corner if it's not already selected.
Click on "Security Groups" in the left-hand navigation pane.
Locate the security group associated with your EC2 instance and select it.
In the "Inbound" tab of the security group details, click on "Edit inbound rules" or "Add rule" button.
Add a new rule for SSH access by selecting "SSH" from the "Type" dropdown menu. This will automatically set the port to 22, which is the default SSH port.
Specify the source IP address range from which you want to allow SSH access. You can choose "My IP" to automatically populate your current public IP address, or you can specify a custom IP range.
Click on "Save" or "Add rule" to apply the changes and update the security group rules.
Then go back on your instance and click connect
If you are experiencing difficulties authorizing the EC2 Instance Connect service when IP addresses and port 22 is already authorized in your security group, you can try the following steps to debug the issue:
Verify Security Group Rules: Double-check the security group rules associated with your EC2 instance. Ensure that there is a rule allowing inbound access on port 22 (SSH) from the EC2 Instance Connect service IP addresses for your region.
Confirm Region Compatibility: Make sure that the region of your EC2 instance and the EC2 Instance Connect service IP addresses match. Each region has its own set of IP addresses for the EC2 Instance Connect service, so it's important to verify that you are using the correct IP addresses for your specific region.
Check VPC and Subnet Configuration: Ensure that your EC2 instance is associated with a VPC (Virtual Private Cloud) and a subnet that allows inbound and outbound traffic. Check the network ACLs (Access Control Lists) and route tables associated with the subnet to ensure they are not blocking SSH traffic.
Verify EC2 Instance Connectivity: Ensure that your EC2 instance is running and accessible. You can try connecting to the instance using other methods such as the EC2 console or SSH with a different SSH client.
Review EC2 Instance Connect Service Documentation: Consult the AWS documentation on EC2 Instance Connect to understand the requirements and troubleshooting steps specific to the service. The documentation provides detailed information on how to authorize the EC2 Instance Connect service IP addresses for your region.
Yay! We have just created our very first linux server in the cloud and our setup looks like this now