Yes, you will also need to fix the permissions of the enclosing directory ~/.gnupg
Because an attacker with enough rights on the folder could manipulate folder contents.
Execute the following commands:
Make sure, the folder+contents belong to you:
chown -R $(whoami) ~/.gnupg/
Correct access rights for
.gnupg
and subfolders:
find ~/.gnupg -type f -exec chmod 600 {} \;
find ~/.gnupg -type d -exec chmod 700 {} \;
Explanation for 600
, 700
:
Lets start from the back: '00' mean NO rights AT ALL for everybody who is not the owner of the files/directories.
That means, that the process reading these (gnupg) must run as the owner of these files/directories.
~/.gnupg/
is a folder, the process reading the contents must be able to "enter" (=execute) this folder. This is the "x" Bit. It has the value "1". 7 - 6 = 1
Both ~/.gnupg/
and ~/.gnupg/*
you want to be able to read and write, thats 4 + 2 = 6
.
==> Only the owner of the files can read/write them now (=600). Only he can enter into the directory as well (=700)
==> These file rights don't "need" to be documented, they are derivable from the intended usage.
More info about permission notation: https://en.wikipedia.org/wiki/File_system_permissions#Notation_of_traditional_Unix_permissions