#!/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 |
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.
Awesome, will keep this for future reference. Thanks a lot @oseme-techguy!
How about using find
?
find ~/.gnupg -type f -exec chmod 600 {} \; # Set 600 for files
find ~/.gnupg -type d -exec chmod 700 {} \; # Set 700 for directories
The internal directory .gnupg
usually contains other directories, so it seems to me that setting permissions through find
would be a better solution.
The commands given by @ElXreno are correct: The directory containing the private keys should be traversable by the user who own it, or GPG won't be able to read the private keys.
I am having trouble with this "gpg: WARNING: unsafe permissions on homedir" on my Windows computer. I have been using gpg4win 3.1.11 (a Windows version of gpg) for over 3 years but I suddenly started to get this warning about a week ago and have been unable to use gpg since then.
Does anybody know what Windows permissions are needed to make gpg4win work again?
Issue: gpg failed to sign the data after git commit -m 'sample text'
I want to push my changes to GitHub in Git command, integrated terminal in VSC, and my profile is Bash, customized in ZSH. I'm deploying to Netlify through continuous deployment from Github.
Every time I do "git commit -m "xyz', I get error:
husky > pre-commit (node v14.17.5)
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.
ℹ No staged files match any configured task.
error: gpg failed to sign the data
fatal: failed to write commit object
We think it is an authentication issue, related to gpg key. We're able to run gpg2, but not able to sign in with key. We're trying to set the program to gpg2, and we have upgraded to gpg2, but it says it is already installed gpg. How to check what is gpg key?
We are not sure where to look/what to do now.
Previously I had problems with visibility of my contributions to Gihub, so I have gained Netlify permission to access my repository code. Netlify does this by installing the Netlify GitHub App on my Github account. Everything worked perfect, until I have updated my Macbook Air from Mojave to Big Sur v11. In the same time I had to update my terminal, so I screwed Homebrew upgrade. Yet, my profile is just Bash. Not sure about the last one, sorry! Not least, but last, Netlify just announced Netlify API Authentication beta version to enable in my settings. I haven't enabled it yet, but I'm not sure if these are the source of my issue.
thanks a lot
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!