Question:
I have a running EC2
instance that is running Linux OS
(Amazon Linux AMI release 2018.03
) on it.
Given that Windows 10
has SSH
client available in the command prompt, I was trying to SSH
into my EC2
instance using the SSH
private key(.pem
file) provided by AWS
as a key pair during the setup of the EC2
instance.
The command I am using on cmd
is :
1 2 |
ssh -i private_key.pem ec2-user@3.133.96.240 |
Here private_key.pem
is the name of the private key file provided by AWS
.
But I keep getting the error:
1 2 3 4 5 6 7 8 9 |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions for 'private_key.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "private_key.pem": bad permissions ec2-user@3.133.96.240: Permission denied (publickey). |
Some things I would like to clarify:
- There are similar questions on StackOverflow. Those questions actually involve trying to connect to the
EC2
instance from a host that is runningMacOS
/Linux
(anyUNIX
based OS). In my case I am trying to connect fromWindows
10 host using command prompt. - In answer to such other questions as discussed in (1), people have suggested trying to change the file permission of the private key file(
.pem
) file to read-only(chmod 444 file.pem
). In response, I tried making my.pem
file as read-only from the file properties in myWindows
. This did not help. I keep getting the same error. - I am able to connect to other remote Linux hosts from my Windows 10 cmd, which suggests there is probably no problem with my Windows 10 SSH client.
- I know this connection can be made easier by using
Putty
instead ofCMD
, but that is not what this question is about. Just assume because of some constraints I cant usePutty
.
Any help would be appreciated.
Answer:
In Windows 10, locate the .pem file in question and right-click on it.
From Properties–>Security–> Advanced:
- Make sure your user is the owner of the file
- Give Read&Execute permissions for your user specifically,
while removing all other permissions on the file for other users or groups.