Uncategorized
How can I SSH into an AWS EC2 instance?
A note on security:
I will not suggest this method unless you are absolutely sure what you are doing. This method requires you to create and use an SSH key pair. You must download the SSH key pair file to your computer.
There is a potential security threat with this approach. Anyone who has the SSH Keypair can log in to the EC2 Instance. For example, in an office environment, if the keys are placed in a shared file storage or collaboration software, then other team members can access the key pairs.
How can I improve the security?
- Never ever, do not place the SSH pair in a shared location, like, git, network storage, etc.
- Update the security groups to block SSH access.
- Restrict SSH access to a specific or range of IP addresses. This method will work if you connect from your private computer or when your team connects from a known IP address range. If you are in the office, there is a chance that other teams’ IP ranges may also get included in the IP address range, so it may not be practical all the time.
- Avoid SSH connection completely and connect from the AWS Console using Session Manager or EC2 instance connect, where you can leverage IAM authentication.
How can I connect using SSH?
- Make sure you have the SSH keypairs
- Update the permissions for the SSH Key pair
- If you are using Linux/Mac, connect from a terminal using ssh utility
Update the permission for the PEM file:
chmod 400 my_ssh_keypair_file.pem
SSH into the EC2 instance:
Specify the name/location of the PEM file when invoking the ssh command, using -i option.
ssh -i "my_ssh_keypair_file.pem" ec2-user@ec2-100-32-21-239.us-west-2.compute.amazonaws.com

Where can I get more info?
You can find more details on this AWS documentation.
-
AWS3 years ago
How to install NodeJS in Amazon Linux 2
-
Infrastructure3 years ago
How to test CPU, Memory and File System Performance using Sysbench
-
AWS3 years ago
How to install .Net 6 in Amazon Linux 2
-
Uncategorized3 years ago
How to install Docker in Amazon Linux 2?
-
Infrastructure3 years ago
How to get Linux OS Information using uname command
-
Infrastructure3 years ago
How to reproduce CVE-2021-44228 (Log4J vulnerability), patch it, and validate the fix
-
Uncategorized3 years ago
Everything, Everywhere, All At Once
-
Linux3 years ago
How to install git in Amazon Linux 2