I have around 50 secret Keys on my Old Server and I have been running script to decrypt the file

c:\gnupg\gpg.exe --passphrase-fd 0 --decrypt --quiet --batch --output "xx.txt" "xx.txt.pgp" I want to start doing this on another server, so I would need to export the private Key to the new Server. Question is that when I run the above command on my old server, it decrypts the file using a private key in those 50 keys, I want to know which private key is that one. How to do this

so I can get the list

c:\gnupg\gpg.exe --list-secret-keys and I can import the Key from there, but I want to find out which key to export. Any help

1 Answer 1


Use --list-packets:

 gpg.exe --list-packets file.gpg


 gpg: encrypted with 3072-bit RSA key, ID 1234567890ABCDEF, created 2021-06-17
  "john <john.smith@example.domain>"

With that e-mail or its ID you may then get the correct key:

 gpg.exe --list-key 1234567890ABCDEF
 gpg.exe --list-key john.smith@example.domain

The above example does not decrypt, but rather only shows information on how it was encrypted.

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.