Cannot SSH to EC2 from Windows
Usually, I am contacted to help resolve issues connecting to EC2
instances from Windows
computers. Two of the most common causes for these problems are,
- The use of an incorrect
username
for the target instance - The credentials file has the wrong permissions
For the first point, it is important to remember the username
is related to the AMI image
used to create the EC2 instance. Only the Amazon AMI images
do have the username ec2-user
, whereas Ubuntu
images have the user ubuntu
. Here’s a list of the default usernames in AWS
source
- For
Amazon Linux 2
or theAmazon Linux AMI
, the user name isec2-user
. - For a
CentOS AMI
, the user name iscentos
orec2-user
. - For a
Debian AMI
, the user name isadmin
. - For a
Fedora AMI
, the user name isfedora
orec2-user
. - For a
RHEL AMI
, the user name isec2-user
orroot
. - For a
SUSE AMI
, the user name isec2-user
orroot
. - For an
Ubuntu AMI
, the user name isubuntu
. - For an
Oracle AMI
, the user name isec2-user
. - For a
Bitnami AMI
, the user name isbitnami
.
For the second point, evidenced by the message Permissions for X are too open
, as seen in the next image.
We need to make sure the credentials file’s permissions allow full control only to the desired windows user. This is done in Windows from the Windows Explorer
as follows,
1. Locate the credential file and right-click
on it
2. From the pop-up menu, select Properties
, and then, in the Properties
dialogue box, click the Security
tab. Then, click on “Advanced”
3. Set the desired user as the Owner
of the file and disable inheritance.
4. Then, remove all entries in the Permission entries
except the desired windows user.
5. The desired windows user should be allowed Full control
.
6. The connection should now be successful
I have found that these two cases solved many of the problems for my clients. Nevertheless, please get in contact If you are still having difficulties connecting to your EC2
instances or if you need support. I can help you solve any issue you may be facing with your AWS
resources.