8

I'm trying to import my PGP identity including secret keys to a new computer by connecting to a computer which has the secret key, and running

ssh othercomputer cat myself.gpg | gpg2 --import

When doing this, it looks like GPG is importing the public keys, but not the private ones. When examining the output closer, I can see that it says "error sending to agent: operation cancelled" which I assume has something to do with the problem.

I have

  • tried specifying a pinentry-program in gpg-agent.conf;
  • restarted gpg-agent and triple-checked it is running; and
  • verified that the versions of gpg-agent and gpg match.
kqr
  • 219

3 Answers3

3

The issue – I think – is that GnuPG detects that it is running in a pipe, i.e. in a non-interactive shell. Since non-interactive means there's no user interacting with it, there is little point in showing a pinentry dialog – at least in most cases.

The easiest solution is to store myself.gpg on the local drive and then import it in a separate command. I understand this solution may have some repercussions in terms of privacy and secrecy, so do understand the consequences of this choice before you blindly follow advice.

kqr
  • 219
3

Set pinentry-mode on the command line or in the ~/.gnupg/gpg.conf file.

--pinentry-mode loopback

or just

pinentry-mode loopback in the config file.

Deathgrip
  • 139
-1

Adding pinentry-mode loopback in the ~/.gnupg/gpg.conf file works for Ubuntu 20.04