我从ssh收到以下错误:

Permissions 0777 for '/Users/username/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.

我应该授予id_rsa文件什么权限?


当前回答

对于我(使用Windows的Ubuntu子系统),错误消息更改为:

 Permissions 0555 for 'key.pem' are too open

在使用chmod 400之后。事实证明,使用root作为默认用户是原因。

使用cmd:

 ubuntu config --default-user your_username

其他回答

我在EC2上使用VPC,并收到相同的错误消息。我注意到我在使用公共DNS。我把它改成了专用DNS和vola!!它奏效了。。。

0600是我的设定值(并且正在工作)

在我的案例中,问题是空白太多。

ssh -i mykey.pem  ubuntu@instace.eu-north-1.compute.amazonaws.com

but

ssh -i mykey.pem ubuntu@instace.eu-north-1.compute.amazonaws.com

工作正常。问题是空白被视为用户名的一部分。

除了公认的答案之外,如果您已经完成了所有建议的方法,并且在windows上使用了“wsl”ubuntu,那么可以在ssh命令中附加“sudo”,例如

sudo ssh-i xxx.pemxxxx@xxxx.compute-1.amazonaws.com

提供400许可,执行以下命令

chmod 400 /Users/username/.ssh/id_rsa