0

I have GPG Suite 2020.1 installed on 2 computers, both running macOS 11.0.1.

I would like to sync my GPG keychain and config files between them, so that adding/trusting a key on one machine is reflected on the other. I imagine this should be possible by syncing one or more files from ~/.gnupg

For the sync mechanism, I will be using Resilio Sync (not a public cloud). However, that should be mostly irrelevant; I imagine one could use git, Syncthing, or even Dropbox (risks of storing private keys on a public cloud notwithstanding!)

Can anyone tell me if this is possible, and how to do it?

2 Answers 2

1

Yes, it is certainly possible. The files in ~/.gnupg are just ordinary text files - there's nothing that "binds" them to one specific machine as such.

You can do it either by adding the files to an already-synced folder, and then linking them into ~/.gnupg - or by choosing ~/.gnupg as the folder where you want data synced to (you can choose that individually for each folder that you sync from Resilio).

0

This is how I ended up doing it. It's working for me with macOS 12.3.1 and GPGSuite 2022.1.

First, set up the main sync dir (do this on the Mac that has the config you want to replicate)

# shut down gpg-agent
gpgconf --kill gpg-agent

# set the var below to whatever path you want to use
GPG_SYNC_PATH=$HOME/Sync/gnupg

# move GPG folder
mv ~/.gnupg $GPG_SYNC_PATH

# create symlink
ln -sv $GPG_SYNC_PATH ~/.gnupg

# set permissions
chmod -h 700 ~/.gnupg
find "$GPG_SYNC_PATH" -type f -exec chmod 600 {} \;
find "$GPG_SYNC_PATH" -type d -exec chmod 700 {} \;

# reload gpg-agent
gpg-connect-agent reloadagent /bye

Then, configure the other Macs to sync with it

gpgconf --kill gpg-agent
GPG_SYNC_PATH=$HOME/Sync/gnupg
mv ~/.gnupg ~/.gnupg.old
ln -sv $GPG_SYNC_PATH ~/.gnupg
chmod -h 700 ~/.gnupg
find "$GPG_SYNC_PATH" -type f -exec chmod 600 {} \;
find "$GPG_SYNC_PATH" -type d -exec chmod 700 {} \;
gpg-connect-agent reloadagent /bye

Permissions fix was based on https://superuser.com/questions/954509/what-are-the-correct-permissions-for-the-gnupg-enclosing-folder-gpg-warning

2
  • Are the two finds relevant on the other Macs? Permissions should get synced from the first Mac I assume.
    – nohillside
    May 9 at 13:20
  • 1
    @nohillside You're right, but depending on the sync solution in use, permissions aren't always replicated. Can't hurt, could help.
    – luckman212
    May 9 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .