Skip to content

Instantly share code, notes, and snippets.

@Avaq
Created November 4, 2014 12:25
Show Gist options
  • Save Avaq/e31ddbd427cffbeab734 to your computer and use it in GitHub Desktop.
Save Avaq/e31ddbd427cffbeab734 to your computer and use it in GitHub Desktop.
Exporting and importing GPG keys over SSH
ssh user@remote gpg --export-secret-key KeyId | gpg --allow-secret-key-import --import
# Based on key ID.
ssh user@remote gpg --export KeyId | gpg --import
# Based on key owner name.
ssh user@remote gpg --export -a KeyOwnerName | gpg --import
gpg --export-secret-key KeyId | ssh user@remote gpg --allow-secret-key-import --import
gpg --export KeyId | ssh user@remote gpg --import
@hsxfjames
Copy link

I ran into several problems, the following should solve them:

  1. error sending to agent: No pinentry: just install pinentry package on target machine.
  2. error sending to agent: No such file or directory: just like @aidenscott2016 said, need to add --batch parameter with --import together.
  3. problem 2 still, run echo pinentry-mode loopback >> ~/.gnupg/gpg-agent.conf and restart gpg agent after gpgconf --kill gpg-agent should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment