Trying to SSH into an Amazon Ec2 instance
This is probably a stupidly simple question to some :)
I've created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me to SSH in.
When I tried to ssh with:
ssh -i myfile.pem <public dns>
I got:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'amazonec2.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: amazonec2.pem
Permission denied (publickey).
Following this post I tried to chmod +600 the pem file, but now when I ssh I just get:
Permission denied (publickey).
What school-boy error am I making here? The .pem file is in my home folder (in osx). It's permissions look like this:
-rw-------@ 1 mattroberts staff 1696 19 Nov 11:20 amazonec2.pem
The problem is having wrong mod on the file.
Easily solved by executing -
chmod 400 mykey.pem
Taken from Amazon's instructions -
Your key file must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 mykey.pem
You are likely using the wrong username to login:
ubuntu
ec2-user
root
or admin
To login, you need to adjust your ssh command:
ssh -l USERNAME_HERE -i .ssh/yourkey.pem public-ec2-host
HTH
I know this is very late to the game ... but this always works for me:
step 1
ssh-add ~/.ssh/KEY_PAIR_NAME.pem
step 2, simply ssh in :)
ssh user_name@<instance public dns/ip>
eg
ssh ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
hope this helps someone.
链接地址: http://www.djcxy.com/p/6642.html上一篇: 亚马逊邮件服务
下一篇: 尝试SSH到Amazon Ec2实例中