“未受保护的私钥文件!"使用 SSH 进入 Amazon EC2 实例 (AWS) 时出错
这对某些人来说可能是一个愚蠢的简单问题:)
This is probably a stupidly simple question to some :)
我在 Amazon EC2 上创建了一个新的 linux 实例,并下载了 .pem 文件以允许我通过 SSH 进入.
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.
当我尝试 ssh 时:
When I tried to ssh with:
ssh -i myfile.pem <public dns>
我得到了:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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).
在这篇文章之后,我尝试将 pem 文件 chmod +600,但现在当我 ssh 时,我得到:
Following this post I tried to chmod +600 the pem file, but now when I ssh I just get:
Permission denied (publickey).
我在这里犯了什么小学生错误?.pem 文件位于我的主文件夹中(在 osx 中).它的权限如下所示:
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
问题是文件的 mod 有误.
The problem is having wrong mod on the file.
通过执行轻松解决-
chmod 400 mykey.pem
取自亚马逊的说明 -
您的密钥文件不得公开查看,SSH 才能正常工作.用这个如果需要,命令:chmod 400 mykey.pem
Your key file must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 mykey.pem
400 通过使其只读且仅供所有者使用来保护它.
400 protects it by making it read only and only for the owner.