516 linux permissions file-permissions macos
我更改了.ssh文件夹中的权限,现在当我使用使用我的私钥的软件时,我每次都必须输入密码。id_rsa每次使用使用它的应用程序时,我对文件的权限应该是什么?
目前我的权限设置为:
-rw-------@ 1 Jody staff 114 Nov 4 23:29 config
-rw------- 1 Jody staff 1743 Oct 21 2009 id_rsa
-rw-------@ 1 Jody staff 397 Oct 21 2009 id_rsa.pub
-rw-------@ 1 Jody staff 3855 Sep 13 22:35 known_hosts
Run Code Online (Sandbox Code Playgroud)
小智 845
通常,您希望权限为:
.ssh 目录: 700 (drwx------).pub文件):644 (-rw-r--r--)id_rsa):600 (-rw-------)755 (drwxr-xr-x))写入。我假设您的意思是每次都必须输入系统/用户密码,而以前您不必这样做。cdhowie 的响应是假设您在生成密钥时设置了密码/密码,如果您按照他所说的那样设置,则除非您使用 ssh 代理,否则每次都必须输入密码。
Ale*_*x W 112
我一直在为此苦苦挣扎,终于弄清楚需要什么。将$USER所有位置替换为您要在服务器上登录的 SSH 用户名。如果您尝试登录,因为root您需要使用/root/.ssh等,而不/home/root/.ssh是非 root 用户的登录方式。
chmod go-w /home/$USERchmod 700 /home/$USER/.sshchmod 644 /home/$USER/.ssh/authorized_keysuser拥有文件/文件夹而不是root:chown user:user authorized_keys和chown user:user /home/$USER/.sshssh-keygen)authorized_keys放在服务器上的用户文件中.ssh您一直在修改的正确文件夹。如果没有,请用于usermod -d /home/$USER $USER解决问题service ssh restart.ssh文件夹中有公钥和私钥文件并登录:ssh user@host.comAsh*_*dal 26
我将此作为单独的答案发布,因为我希望看到手册页建议转换为权限。
基于手册页引用的摘要(链接在最后):
+------------------------+-------------------------------------+-------------+-------------+
| Directory or File | Man Page | Recommended | Mandatory |
| | | Permissions | Permissions |
+------------------------+-------------------------------------+-------------+-------------+
| ~/.ssh/ | There is no general requirement to | 700 | |
| | keep the entire contents of this | | |
| | directory secret, but the | | |
| | recommended permissions are | | |
| | read/write/execute for the user, | | |
| | and not accessible by others. | | |
+------------------------+-------------------------------------+-------------+-------------+
| ~/.ssh/authorized_keys | This file is not highly sensitive, | 600 | |
| | but the recommended permissions are | | |
| | read/write for the user, and not | | |
| | accessible by others | | |
+------------------------+-------------------------------------+-------------+-------------+
| ~/.ssh/config | Because of the potential for abuse, | | 600 |
| | this file must have strict | | |
| | permissions: read/write for the | | |
| | user, and not accessible by others. | | |
| | It may be group-writable provided | | |
| | that the group in question contains | | |
| | only the user. | | |
+------------------------+-------------------------------------+-------------+-------------+
| ~/.ssh/identity | These files contain sensitive data | | 600 |
| ~/.ssh/id_dsa | and should be readable by the user | | |
| ~/.ssh/id_rsa | but not accessible by others | | |
| | (read/write/execute) | | |
+------------------------+-------------------------------------+-------------+-------------+
| ~/.ssh/identity.pub | Contains the public key for | 644 | |
| ~/.ssh/id_dsa.pub | authentication. These files are | | |
| ~/.ssh/id_rsa.pub | not sensitive and can (but need | | |
| | not) be readable by anyone. | | |
+------------------------+-------------------------------------+-------------+-------------+
Run Code Online (Sandbox Code Playgroud)
所有手册页引用均来自http://linuxcommand.org/lc3_man_pages/ssh1.html
权限应该与此无关。您的私钥是用密码加密的,因此您需要输入密码才能解密和使用私钥。
您可能会考虑运行 ssh 代理,它可以缓存解密的密钥并将它们提供给需要它们的应用程序。
小智 5
Felipe 是正确的——包含您的 .ssh 目录的目录不能被组或其他人写入。因此chmod go-w ~,如果在运行 ssh 后仍然提示您输入密码ssh-keygen -t rsa; cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys,假设您没有在 ssh-keygen 命令中分配密码,并且您的 .ssh 目录在您的主目录中,那么下一个合乎逻辑的尝试是。
| 归档时间: |
|
| 查看次数: |
600726 次 |
| 最近记录: |