通过符号链接的许可

通过符号链接的许可

用户 (33) 无法读取 web.{crt,key} 文件。我是否必须通过所有链接给予许可,或者是否有一个聪明的方法来做到这一点?

# ll /mnt/efs/cert
total 20
-rw-r--r-- 1 33 tape 1237 Oct  9 14:30 dag.crt
-rw-r--r-- 1 33 tape 1704 Oct  9 14:30 dag.pem
drwxr-xr-x 2 33 tape 6144 Dec  7  2018 ldap
lrwxrwxrwx 1 33 tape   74 Oct 14 12:13 web.crt -> /etc/letsencrypt/live/domain/fullchain.pem
lrwxrwxrwx 1 33 tape   72 Oct 14 12:13 web.key -> /etc/letsencrypt/live/domain/privkey.pem
# ll /etc/letsencrypt/live/domain/
total 4
lrwxrwxrwx 1 root root  62 Oct 14 12:01 cert.pem -> ../../archive/domain/cert1.pem
lrwxrwxrwx 1 root root  63 Oct 14 12:01 chain.pem -> ../../archive/domain/chain1.pem
lrwxrwxrwx 1 root root  67 Oct 14 12:01 fullchain.pem -> ../../archive/domain/fullchain1.pem
lrwxrwxrwx 1 root root  65 Oct 14 12:01 privkey.pem -> ../../archive/domain/privkey1.pem
-rw-r--r-- 1 root root 692 Oct 14 12:01 README
# ll /etc/letsencrypt/archive/domain/
total 16
-rw-r--r-- 1 root root 1972 Oct 14 12:01 cert1.pem
-rw-r--r-- 1 root root 1647 Oct 14 12:01 chain1.pem
-rw-r--r-- 1 root root 3619 Oct 14 12:01 fullchain1.pem
-rw------- 1 root root 1708 Oct 14 12:01 privkey1.pem

答案1

我想添加评论,但评论需要 50 点声誉。

根据我的信息,所有链接都指向的最终文件的访问权限很重要,因为它是您尝试访问的文件。由于privkey1.pemin的访问权限/etc/letsencrypt/archive/domain/不允许除 之外的任何用户进行读访问root,因此除了 root 之外的任何用户都无法访问它。

您应该将其权限更改为“644”,以向其他用户授予读取权限。

chmod 0644 /etc/letsencrypt/archive/domain/privkey1.pem

答案2

首先,需要检查用户 (33) 是否属于打字组。如果磁带组不存在,则应创建它。

要显示属于键入的组的用户,可以使用以下命令:

sudo groups tape

要将用户(33)添加到打字组,可以使用以下命令

sudo gpasswd -a $(getent passwd 33|cut -d: -f1) type

然后,要使每个文件可读写,您可以使用以下命令:

for d in /mnt/efs/cert /etc/letsencrypt/live/domain/ /etc/letsencrypt/archive/domain/; for f in $(ls $d);do chmod g+rw $f;done ;done

相关内容