How to Connect EC2 instance from Remotely | Linux | AWS
The previous article we have seen that how to create an Amazon EC2 Instance using with Linux image (Amazon AMI). In this article, we will see how to Connect EC2 instance from remotely. After launching your first instance on AWS, it important to know how can we connect the cloud instance using withan.pem/.ppk file from Linux/Windows Clint system. Here we are providing the step by step guide to log in your EC2 Instance. AWS EC2 instance login is totally deferent from regular login of servers. It will use the private key to access your Amazon EC2 Linux instances. While creating an Amazon EC2 Instance it will ask you to create/use the public key pair to log in to you an instance first time. A key pair is a set of public-private keys.
AWS EC2 instance login is bit deferent from regular login of your own Servers. because we’re not creating any user while selecting your AMI. by default Amazone EC2 Instances(Linux) will use the private key to access the EC2 Linux instances. While creating an Amazon EC2 Instance it will ask you to create/use the public key pair to log in to you an instance first time. A key pair is a set of public-private keys.
AWS EC2 instance stores the public key in the instance, and after generating the key that will ask to download the private key.
Make sure you download the key and keep it safe and secured, if it is lost you cannot download it again without your public key.
Once you are done downloading and saving your key, launch your instance. After clicking on Launch Instances, within a minute your will be ready on AWS.
When you download your key, it will look as RSA private key.
Once Instance state is up and running, you will see the instance details as below. We don’t assign any EIP here. Here We are using dynamic public IP to connect the Linux Instance.
From Windows machine, we will use ssh client like Putty/MobaXterm to connect Linux Instance. Now open putty from your windows programs list and add your Public IP/EIP of the instance in there as below.
Access/Connect EC2 Instance from Windows machine:
In this step, we are trying to connect AWS EC2 instance from Windows machine using putty,
Add your private key in putty for secure connection
- Provide the Public IP/DNS Name of your EC2 instance
- Go to SSH -> Auth
- Add your private key in .ppk (putty private key) format
Once done above steps, just click on “Open” button to connect your instance through ssh protocol.
- The first time it will ask you to save known host details as below
- Once you connect, you will successfully see the Linux prompt. In AWS every Linux instance default user is ec2-user. use the ec2-user to login
- Please note that the machine you are connecting from outside, it should be enabled on the instance Security Group for SSH protocol and the proper port to access it.
Note: Amazon Web Services is providing deferent users for deferent AMI’s. Make sure note down and use the proper user with private to log in your instances.
From putty/Terminal enter
public_IP/dns_name to login to your Linux Instance. Make sure to use the appropriate user name for your AMI. Below is the list of users for deferent AMI’s.
For an Amazon Linux AMI, the user name is
For a RHEL AMI, the user name is
For an Ubuntu AMI, the user name is
For a Centos AMI, the user name is
For a Fedora AMI, the user name is
For SUSE, the user name is
rootwork, check with the AMI provider.
Access/Connect EC2 Instance from Linux machine:
- From your linux shell, use ssh command to connect your remote server. The command will look like as below
- # ssh –i appserver03.pem [email protected]
- ssh: Command-line utility to connect your remote linux systems
- appserver03.pem: the private key of the appserver03 instance on AWS.
- ec2-user: The default user in Linux instances on AWS.
- 22.214.171.124: The public IP address of the Linux Instance.
Conclusion: I hope this article is helpful to understand the next step of how to Connect EC2 instance from remotely. operations on AWS. Once you become familiar with the AWS EC2 Service and remote login, it becomes a matter of 2 minutes to launching the new instances and it’s administration on AWS.!