Hot answers tagged

393 votes

How to export a GPG private key and public key to a file

Export Public Key This command will export an ascii armored version of the public key: gpg --output public.pgp --armor --export username@email Export Secret Key This command will export an ascii ...
RubberStamp's user avatar
  • 7,208
188 votes

gpg: keyserver receive failed: No dirmngr

Installing the package dirmngr fixed the error. user@debian-server:~$ sudo apt-get install dirmngr Retrying : user@debian-server:~$ sudo apt-key adv --keyserver hkp:// --recv-...
Hunter.S.Thompson's user avatar
181 votes

How to import secret gpg key (copied from one machine to another)?

Above is only a partial answer. Complete answer is: gpg --import private.key Given the KEYID (e.g FA0339620046E260) from the output: gpg --edit-key {KEY} trust quit # enter 5<RETURN> (I ...
cmcginty's user avatar
  • 2,683
86 votes

gpg: keyserver receive failed: Server indicated a failure

Behind a firewall you should use the port 80 instead of the default port 11371 : sudo apt-key adv --keyserver hkp:// --recv 9A2FD067A2E3EF7B Sample output: Executing: /tmp/...
GAD3R's user avatar
  • 66.3k
83 votes

Unable to add gpg key with apt-key behind a proxy

You usually have a proxy for ftp, http and https; I am seeing there hkp:// as an URL; so it should not be directed via a pure http proxy, hence failing the communication. Use this instead: sudo apt-...
Rui F Ribeiro's user avatar
79 votes

gpg —list-keys command outputs uid [ unknown ] after importing private key onto a clean install

GNUPG has a trust database stored at ~/.gnupg/trustdb.gpg You can backup this trust database using the --export-ownertrust option: gpg --export-ownertrust > file.txt If you exported your secret ...
RubberStamp's user avatar
  • 7,208
72 votes

zshrc export GPG_TTY=$(tty) says not a tty

tty command requires that stdin is attached to a terminal. When using Powerlevel10k, stdin is redirected from /dev/null when Instant Prompt is activated and until Zsh is fully initialized. This is ...
Roman Perepelitsa's user avatar
63 votes

"No such file or directory" when generating a gpg key

Did you delete the /home/me123/.gnupg directory and then it was recreated by gpg? If so, that's likely what is confusing the agent. Either restart the agent (gpgconf --kill gpg-agent) or, more ...
tupiniquim's user avatar
63 votes

gpg: WARNING: unsafe ownership on homedir '/home/user/.gnupg'

This is the result of running gpg with sudo: gpg then runs as root, but its home directory is still the user’s. This explains both the warning (gpg is running as root but another user owns the ...
Stephen Kitt's user avatar
61 votes

Gentoo Linux GPG encrypts properly a file passed through parameter but throws "Inappropriate ioctl for device" when reading from standard input

You should set the GPG_TTY environment variable for it to work, as in this document: GPG_TTY=$(tty) export GPG_TTY Those two lines are supposed to be in your ~/.bashrc (assuming bash), so they're run ...
TNW's user avatar
  • 2,100
61 votes

How to renew an expired encryption subkey with gpg

List your keys. $ gpg --list-keys ... ------------------------------- pub rsa2048 2019-09-07 [SC] [expires: 2020-11-15] AF4RGH94ADC84 uid [ultimate] Jill Doe (CX) <jilldoe@mail....
cgl's user avatar
  • 1,151
58 votes

gpg asks for password even with --passphrase

For gpg version 2.x you don't need to use --batch, just --pinentry-mode loopback works with --passphrase & --passphrase-file, and will let you enter new info, in case of filename conflicts ...
Xen2050's user avatar
  • 2,336
57 votes

Set default key in gpg for signing

To choose a default key without having to specify --default-key on the command-line every time, create a configuration file (if it doesn't already exist), ~/.gnupg/gpg.conf, and add a line containing ...
Stephen Kitt's user avatar
47 votes

How to identify gpg key IDs so they may be deleted

The keyid is the last 8 characters of the gpg key's fingerprint, which is that long hex-code under pub In your case it is: sudo apt-key del C9A97C2C Reference: How can I remove gpg key that I ...
mja's user avatar
  • 1,375
45 votes

How to export a GPG private key and public key to a file

List the keys you have: gpg --list-secret-keys Export the key: gpg -o ~/my-key.asc --export-secret-key name Copy it on another machine; Import the key: gpg --import my-key.asc
Serj Sp's user avatar
  • 559
42 votes

GPG Hangs When Private Keys are Accessed

I came across this exact issue (OSX Sierra 10.12.6, gpg/GnuPG 2.2.5) Commands that would hang: gpg -K # --list-secret-keys gpg -d # --decrypt gpg --edit-key gpgconf --kill gpg-agent My solution was ...
CoffeeMonster's user avatar
40 votes

How can I find out what keys gpg-agent has cached? (like how ssh-add -l shows you cached ssh keys)

On later versions of GnuPG (tested with 2.2.9) it is also possible to list the keygrips that are currently cached by the agent using the command keyinfo --list with gpg-connect-agent. $ gpg-connect-...
GeoffreyFrogeye's user avatar
39 votes

gpg does not ask for password

This is normal, gpg now uses gpg-agent to manage private keys, and the agent caches keys for a certain amount of time (up to two hours by default, with a ten minute inactivity timeout). To change the ...
Stephen Kitt's user avatar
35 votes

How can I remove the passphrase from a gpg2 private key?

As of gpg version 2.4.3, gpg --edit-key <keyid> passwd seems to work fine for removing a passphrase. Issue the command, then provide your current passphrase and then the new one. Just type Enter ...
Eugene Yarmash's user avatar
33 votes

GnuPG command to show key info from file

The good folks at the [email protected] mailing list had the answer: For versions >= 2.1.23: cat keyfile.key | gpg --with-colons --import-options show-only --import For versions >= 2.1.13 but &...
rexroni's user avatar
  • 1,488
31 votes

How to import keys from a keyserver using gpg in debian?

gpg --keyserver --recv-keys DAD95197 is supposed to import keys matching DAD95197 from the MIT keyserver. However the MIT keyserver often has availability issues so it’s safer to ...
Stephen Kitt's user avatar
30 votes

sks-keyservers gone. What to use instead?

Which keyservers can I use for gpg --keyserver "$keyserver1" --recv-key keyid that I can expect not will go away anytime soon? The recommendation is to use, however this ...
fuzzydrawrings's user avatar
26 votes

Unable to add gpg key with apt-key behind a proxy

Here is a solution that uses http via curl instead of trying to proxy apt-key or gpg: curl -sSL \ '' ...
Dan Anderson's user avatar
  • 1,111
25 votes

GnuPG command to show key info from file

For newer versions: gpg --show-keys my-local-key.asc From the man page: --show-keys This commands takes OpenPGP keys as input and prints information about them in the same way the command --list-...
user519428's user avatar
25 votes

How can I automate gpg decryption which uses a passphrase while keeping it secret?

Store the passphrase in a file which is only readable by the cron job’s user, and use the --passphrase-file option to tell gpg to read the passphrase there. This will ensure that the passphrase isn’t ...
Stephen Kitt's user avatar
25 votes

How to update expired Skype signing key

The solution is pretty simple, Microsoft keeps their updated GPG signing key in this file: So, one can do for example: curl -s
Vlastimil Burián's user avatar
24 votes

keyserver receive failed (on every keyserver available)

I was getting the same 'gpg keyserver connection refused' error with gpg at the command line, GPA, and KGpg. I am using gnupg 2.1.18-8 on Debian Sid. I enabled debugging in dirmngr as follows: sudo ...
Jeffrey Brown's user avatar
22 votes

GPG key server for key search?

“Reputable” key servers exchange key updates with others, so using one is the same as using another (with slight delays in some cases). In the past, the recommendation was to use the SKS server pool, ...
Stephen Kitt's user avatar
22 votes

gpg: keyserver receive failed: Server indicated a failure

This issue was really tough for me; none of the proposed solutions worked for me until I found this post on reddit. I just went and added this line to /etc/resolv.conf: nameserver # Google DNS ...
Nafaa Boutefer's user avatar
20 votes

gpg: error retrieving '[email protected]' via WKD

Extending key expiration date fixed the problem. The error message was misleading. However adding -vv as Jens Erat suggested produced some useful error messages such as gpg: Note: signature key ... ...
mehdix's user avatar
  • 695

Only top scored, non community-wiki answers of a minimum length are eligible