我从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文件什么权限?


当前回答

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

chmod 400 /Users/username/.ssh/id_rsa

其他回答

什么对我有用

chgrp用户文件夹chmod 600折叠

我尝试了对我的私钥进行600级的权限,结果成功了。

chmod 600 privateKey 
[dev]$ ssh -i privateKey user@ip

另一方面

chmod 755 privateKey 
[dev]$ ssh -i privateKey user@ip

给出以下问题:

Permissions 0755 for 'privateKey' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "privateKey": bad permissions

我正在使用Windows 10,并尝试通过SSH连接到EC2实例。不要使用Cygwin for Windows,而是尝试使用Git Bash。在为密钥执行chmod 400之后,我可以通过SSH连接到EC2实例,但从Cygwin看,这一点不适用。Windows将.pem文件视为来自internet并阻止它,即使禁用继承也不起作用。

我将文件转换为.ppk格式,PuTTY也能正常工作,但Cygwin无法正常工作。

适用于Windows 8.1的独立于区域设置的解决方案是:

chgrp 545 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

GID 545是一个特殊的ID,它总是指“用户”组,即使您的语言环境使用了不同的“用户”。

我将所有自己的证书和密钥保存在一个目录中,这适用于PuTTY之类的工具,但我从scp命令中收到了一条过于开放的错误消息。我发现Windows已经维护了一个C:\users\ACCOUNTNAME\.ssh文件夹,该文件夹具有存储ssh密钥的适当访问权限。只要您备份内容(Windows有时会在更新期间删除内容),或者在用户文件夹中为ssh密钥创建自己的文件夹,这将很好,因为只有您和管理员才能访问该父文件夹。

在更改Windows文件夹的访问权限时要非常小心。我这样做了,每天Windows都会扫描、读取和写入我的C:驱动器上的所有文件,这一过程会让电脑慢很多分钟。