用户主目录中文件的默认所有者/权限
我经常看到用户尝试修复问题并在某处读取或只是尝试以递归方式chown
其主目录,有时甚至还会递归重置权限,如rwxr-xr-x
或类似内容。
想象一下这样的拥有者/许可大屠杀 – 是否存在需要特殊权限的关键文件/目录,或者是根系所有以使系统工作?
~
NO文件必须由root拥有。
如果某个软件要求您的主目录中的文件由另一个用户拥有,那么这是一个错误,应该如此报告。
除此之外,一个常见的案例涉及两个与安全相关的软件,这些软件需要对某些文件的限制权限,即:
- SSH
- GPG
SSH
参见man ssh
,文章部分:
~/.ssh/config This is the per-user configuration file. The file format and configuration options are described in ssh_config(5). Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not writable by others. It may be group-writable provided that the group in question contains only the user. ~/.ssh/identity ~/.ssh/id_dsa ~/.ssh/id_ecdsa ~/.ssh/id_ed25519 ~/.ssh/id_rsa Contains the private key for authentication. These files contain sensitive data and should be readable by the user but not acces‐ sible by others (read/write/execute). ssh will simply ignore a private key file if it is accessible by others. It is possible to specify a passphrase when generating the key which will be used to encrypt the sensitive part of this file using 3DES.
其他文件如authorized_keys
, known_hosts
等应该只能由用户写入,但可以是世界可读的。
GnuPG的
~/.gnupg
(和内容)只能由您访问。 有了其他权限,GPG会抱怨不安全的权限。
通常,您家中的文件和目录应归您所有。
我有一些奇怪的root拥有的文件,可能是执行sudo
命令的结果; 实际上有一些程序可以在$HOME
下编写东西(其中表现良好的程序需要超级用户权限不应该这样做 – 效果是root取得应该属于用户的文件的所有权)。
通常删除或重新拥有它们(取决于文件)不会产生问题,并且通常会解决一些问题,例如臭名昭着的.Xauthority
文件—有时候,在运行sudo dconf-editor
,你可以使用配置中的东西。再修改了。
关于特殊模式:
- 脚本必须是可执行的,当然,至少对所有者来说;
- 所以必须是目录(其中
x
表示正确交叉); -
.ssh
必须是drwx------
(0700)和其中的私钥-rw-------
(0600) - 如果你有一个
Public
目录进行共享,它应该是drwxr-xr-x
(对任何人的读权限)或drwxrwxrwt
(具有写权限和粘滞位,用于启用写入)。
……我想不出更需要特殊待遇的事情。