2010-02-02 281 views
24

我在运行此代码时遇到此错误。

gpg --fingerprint 

GPG:警告:在 配置文件不安全所有权 `/home/dylan/.gnupg/gpg.conf

这个问题似乎是与权限,但我已尽力这个代码,它似乎没有改变一件事情。通过鹦鹉螺检查,我拥有该文件并具有读取/写入权限,并且所有其他设置为“无”。

sudo chmod 600 ~/.gnupg/gpg.conf


[email protected]:~$ sudo chown -R dylan ~dylan/.gnupg 
[sudo] password for dylan: 
[email protected]:~$ chmod 600 ~/.gnupg/gpg.conf 
[email protected]:~$ chmod 700 ~/.gnupg 
[email protected]:~$ gpg --fingerprint 
[email protected]:~$ sudo gpg --fingerprint 
gpg: WARNING: unsafe ownership on configuration file `/home/dylan/.gnupg/gpg.conf' 
[email protected]:~$ ls -al /home/dylan/.gnupg 
total 24 
drwx------ 2 dylan dylan 4096 2010-02-02 13:46 . 
drwxr-xr-x 60 dylan dylan 4096 2010-02-02 13:43 .. 
-rw------- 1 dylan dylan 9364 2010-01-27 06:34 gpg.conf 
-rw------- 1 dylan dylan 0 2010-01-27 06:34 pubring.gpg 
-rw------- 1 dylan dylan 0 2010-01-27 06:34 secring.gpg 
-rw------- 1 dylan dylan 40 2010-01-27 06:34 trustdb.gpg 
[email protected]:~$ 
+1

@Nona:正如我之前所说的,sudo(8)命令以'root'(系统管理员)身份执行命令。当你是root的时候,你可以做任何事情,你用chmod(1)改变的权限不涉及'root'。这就是为什么你从gpg(1)得到警告。 'dylan @ Majuscule:〜$ gpg --fingerprint'它应该做什么? – emil 2010-02-03 08:04:33

回答

41

命令用于sudo运行将如根运行。你想要做的是拥有这些文件作为你的用户dylan,对吧?

也许正是因为root拥有你的文件。这可以通过更改:

sudo chown -R dylan ~dylan/.gnupg 

,然后作为dylan

chmod 600 ~/.gnupg/gpg.conf 
chmod 700 ~/.gnupg 

检查结果:

ls -l ~/.gnupg 
ls -ld ~/.gnupg 

字母向左书写ls后表示:

r阅读权限(4), w写访问(2), x执行接取(1)

所以6 = 4 + 2 - >读取和写入访问

而且7 = 4 + 2 + 1 - >读,写并执行访问

要能够进入目录,您需要执行访问权限。

如果您想要创建一个只能遍历但不列出文件的目录,可以这样做:chmod 100 the_directory

阅读chmod(2)手册了解更多信息。

1

运行gpg命令作为dylan(即不与sudo),你不会看到错误。您不必以root用户身份访问您的用户拥有的GPG密钥。

相反,您可以通过指定--homedir选项来以root身份访问其他用户的GPG密钥。在这种情况下,您仍然会看到错误,除非您正在访问根用户的GPG密钥。