Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/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
@sf9v

This comment has been minimized.

Copy link

@sf9v sf9v commented Oct 26, 2020

Thanks a lot, this fixed the gpg warning!

I'm curious about how it fixed the warning, can you please explain a bit, specifically line 8 and 9?

Thanks in advance!

@oseme-techguy

This comment has been minimized.

Copy link
Owner Author

@oseme-techguy oseme-techguy commented Oct 27, 2020

@sf9v,

Glad that this helped to fix the warning.

Line 8 changes the permissions on the files in the ~/.gnupg/* directory to 700. 700 means that only the owner/creator can Read, Write and Execute on the files in the directory. Also group and others cannot perform any operation on the files in the directory.

Line 9 changes the permissions on the ~/.gnupg directory to 600. The 600 directory permission means that only the owner/creator of the directory can Read and Write but can't Execute on the directory. The group and others cannot perform any operation on the directory.

@sf9v

This comment has been minimized.

Copy link

@sf9v sf9v commented Oct 28, 2020

Awesome, will keep this for future reference. Thanks a lot @oseme-techguy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.