AWS EC2拒绝SSH登录:“Permissions for 'xxxx.pem' are too open.”

本文解决在使用SSH连接EC2实例时遇到的.pem文件权限错误问题,详细介绍了如何在Windows和Linux下修改.pem文件的安全属性,确保只有文件所有者拥有完全控制权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误如下:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'ec2-user.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 "ec2-user.pem": bad permissions
ec2-user@xxx.xxx.xxx.xxx: Permission denied (publickey).

参考资料:
https://stackoverflow.com/questions/8193768/trying-to-ssh-into-an-amazon-ec2-instance-permission-error

In windows you can go to the properties of the pem file, and go to the security tab, then to advance button.
remove inheritance and all the permissions. then grant yourself the full control. after all SSL will not give you the same error again.

需要将下载的.pem文件的安全属性更改为仅自己完全控制,其他成员的权限都要删掉。
在linux下,可以用

chmod 400 mykey.pem

在windows下,比较麻烦,步骤如下:

  1. 右键点击文件,选择“属性”->“安全”->“高级”
  2. 点击“禁用继承”按钮,将所有用户的访问权限删掉。
  3. 点击“添加”
    最后看起来像这个样子
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值