An instance is a virtual environment in the AWS cloud to run applications on the Amazon Web Services (AWS) infrastructure. Users can use Amazon Machine Image (AMI) to launch an instance. AMI provides an operating system, application server, and necessary applications to run the server.
AWS provides free tier EC2 instances for the first year, where the user can use the t2.micro instance for free. For usage after the first year of signing up or using non-free tier instances, the user has to pay a fee. If you are concerned with if the cost is worth hosting your application, there might be various things to consider (Is AWS Web Hosting Worth It? – EnableGeek).
To log in to an instance, SSH protocol can be used. SSH or Secure Shell protocol is a cryptographic protocol that securely connects two computers over an unsecured network. By using SSH we can log in to a remote computer, and execute shell commands with a high level of security. Generally, for a better user experience you need to have a certain level of adequacy with command shells to execute commands. But there are graphical interfaces such as WinSCP for Windows and Cyberduck for Mac OS X to help you use SSH.
In this article, we will launch an EC2 instance with step-by-step guidance for beginners. We will also use SSH to log in to our EC2 instance to run our web applications.
Launching EC2 Instance in AWS
In this section, we will launch an EC2 instance from the AWS console. The AWS console interface is very user-friendly. It will take minimum effort for you to launch an EC2 instance.
Prerequisites
- An AWS account.
- You will need to add credit information. For the first year, you can use free tier resources. So if you are careful about not using priced resources, don’t worry about the cost.
Take your coding skills to the next level with our comprehensive guides, “Python Beginner to Advanced” and “Java Beginner to Advanced.” Whether you’re diving into Python or mastering Java, these books provide step-by-step guidance and in-depth knowledge to elevate your programming expertise.
Simply Launching EC2 Instance for Beginners
- From ‘All services’ under the ‘Compute’ section select EC2.
- First, you must select an availability zone that is closer to your desired area. The availability zone assigns the physical zone of the server in which the application will be deployed. Choosee this near your current location for now.
- In the EC2 panel, go to instances, then click ‘Launch instances’.
- Under ‘Name and tags’ use a preferred tag to search instances later for ease of use. This is used to group and filter instances.
Select the ‘Amazon Linux 2 AMI’ with free tier eligibility. There are other free AMIs. You can test out those if you like.
For ‘Instance type’ select t2.micro with free tier eligibility. It will not cost you for the first year of usage.
In Key pair login, click on create new key pair.
It will open up a modal. Use a key pair name. Select the private key file format as .ppk if yuseing putty in windows. If you are using OpenSSH in Linux, select .pem. Then click on ‘Create key pair’. You can use this key to log in to your EC2 instance using SSH.
A .ppk file will be downloaded to your computer. Save it for login with SSH.
- Keep the network settings and configure storage as it is. The default settings will work for now.
- Then click Launch instance.
- If everything goes well, you should see a success screen.
In the instances pane, the instance should be running.
Congratulations on successfully launching an instance! So what next? In the network settings, we had allowed access through SSH. So in the next section, we will discuss how to log in with SSH.
SSH to AWS EC2 from Windows
In this section, we are going to log in to an AWS EC2 instance with SSH from Windows OS. But most of the steps apply to other OSs also.
Prerequisites
- An AWS account with credit info added.
- A launched instance in the AWS console (Launching EC2 Instance in AWS).
Step By Step Guide
- Download and install the PuTTY. PuTTy is a popular software for SSH for Windows users.
- Copy the public IP from the launched instance’s details.
- Open up PuTTY and in the ‘Host Name (or IP address)’ input box, paste the IP. Select the connection type as SSH and port as 22.
- Then in the Connection> SSH> Auth page in the private key for authentication field select your private key that was downloaded when launching the instance. The private key makes communication sec so that so no one can log in to your instances without the private key.
- Then click open.
A login page will open. Enter ec2-user (it’s the default user created by EC2 while launching)
If you are logging in for the first time, to save the key click accept.
If everything goes well you should see a Linux prompt where you can run server commands.
- Test with by updating.
sudo yum update
The terminal will now work as a normal Linux terminal where you can install packages, run applications, and so on.
Congratulations on your first login with SSH to your EC2 instance! We hope you enjoyed getting started on the AWS cloud platform!