-
Star
(131)
You must be signed in to star a gist -
Fork
(23)
You must be signed in to fork a gist
-
-
Save oseme-techguy/bae2e309c084d93b75a9b25f49718f85 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error | |
# Make sure that the .gnupg directory and its contents is accessibile by your user. | |
chown -R $(whoami) ~/.gnupg/ | |
# Also correct the permissions and access rights on the directory | |
chmod 600 ~/.gnupg/* | |
chmod 700 ~/.gnupg |
One command.
chmod -R u=rw,u+X,go= ~/.gnupg/
Or, even easier, with assumption that we DO have correct access to the directory already, and merely want to fix permissions:
chmod -R go= ~/.gnupg/
Also note that this only works on POSIX systems.
I'm still learning Linux; what is it "go=" in
chmod -R go= ~/.gnupg/
mean?
~ thank for this btw
I'm still learning Linux; what is it "go=" in
chmod -R go= ~/.gnupg/
mean?
Unix/Linux file permissions have rights for the user, group, and other. A file is owned by a user and a group, and you can set read, write and execute permissions for the owning user, group, and all other users.
chmod
uses u
, g
, and o
as shorthand for "user", "group" and "other" respectively. You can also use a
for all users.
Some examples:
u=rw
sets the permissions to read and write (and removes the execute permission) for the userg+x
adds the execute permission for the group, bur doesn't change the other permissions (resd and write stay unchanged)o-w
removes the write permission for other users, but doesn't change read and execute permissionsa+X
adds the execute permission for all users, but only for directories (nor for files); very useful when recursively setting permissions with-R
(the execute permission for a directory is needed to be able to list files)
So, go=
sets the group and other permissions to an empty list for the group and other users. In other words, it removes all permissions for the group and other users. You could also use go-rwx
(a bit more descriptive, but longer).
sudo
without an explicit user specification defaults to user#0
(usually namedroot
).Please show an actual output of
sudo getfacl /root/.gnupg
for further diagnostics.