1

I can decrypt file on one machine, but on another one it says "can't check signature" (but still decrypts file).

$ sudo gpg --lock-never -o update.tar -r my@email.com --decrypt myfile.sig
gpg: Signature made <DATETIME>
gpg:                using RSA key <KEY>
gpg: Can't check signature: No public key

How can I find public key on a machine where it works?


Decryption works, i.e. I am seeing update.tar and it is not corrupted. The only problem only is error message about signature check. On one machine I have it and on another I don't. I.e. another machine has public key to check signature somewhere. How to find it?

2
  • Decryption works. The problem is error message only "Can't check signature: No public key". How to get rid of it?
    – Dims
    Mar 22, 2021 at 7:40
  • Probably doesn't work because of a difference of gpg version (happened to me too a while ago when moving distros). Check my answer to see if it work for you. Mar 22, 2021 at 8:01

1 Answer 1

3

You may need to reimport/export your keys and import them:

run this in a file, make sure you run chmod +x file first.

#!/bin/bash
your_id_here="$@"
#your_id_here is your ID.:

#Export keys and ownertrust:
exportkey() {
gpg --export --armor $your_id_here > $your_id_here.pub.asc
gpg --export-secret-keys --armor $your_id_here > $your_id_here.priv.asc
gpg --export-secret-subkeys --armor $your_id_here > $your_id_here.sub_priv.asc
gpg --export-ownertrust > $your_id_here.ownertrust.txt
}
exportkey

Run as ./file id on the commandline, or modify this as you will.

To make it easier to move around, run this in a folder and then tar it.

To import them:

#!/bin/bash
your_id_here="$@"
importkey() {
gpg --import $your_id_here.pub.asc
gpg --import $your_id_here.priv.asc
gpg --import $your_id_here.sub_priv.asc
gpg --import-ownertrust $your_id_here.ownertrust.txt
}
importkey

Same thing as above ./file2 id.

Of course, do untar them first before running this.

PS:

  • It will obviously prompt you for your password, which you usually have when it come to gpg.

  • Just bear in mind it might ask you for your password more than once (think 2 times) because of the two priv key, the rest won't ask for it i believe (unless of course you have the cache setting set in the gpg-agent.conf, in which case it will ask either once or none).

  • Lastly, this only work as a per-id cases. So you'd have to list the ids of your keys yourself by using gpg -k then copy pasting the id that you'd want to backup...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.