gpg decryption fails with no secret key error

后端 未结 9 709
一生所求
一生所求 2020-12-13 17:48

I have a gpg .key file that is used as passphrase for decrypting a .dat.pgp file. The encrypted .data.pgp file gets successfully decrypted on one server with same .key file

9条回答
  •  旧时难觅i
    2020-12-13 18:24

    When migrating from one machine to another-

    1. Check the gpg version and supported algorithms between the two systems.

      gpg --version

    2. Check the presence of keys on both systems.

      gpg --list-keys

      pub 4096R/62999779 2020-08-04 sub 4096R/0F799997 2020-08-04

      gpg --list-secret-keys

      sec 4096R/62999779 2020-08-04 ssb 4096R/0F799997 2020-08-04

    Check for the presence of same pair of key ids on the other machine. For decrypting, only secret key(sec) and secret sub key(ssb) will be needed.

    If the key is not present on the other machine, export the keys in a file from the machine on which keys are present, scp the file and import the keys on the machine where it is missing.

    Do not recreate the keys on the new machine with the same passphrase, name, user details as the newly generated key will have new unique id and "No secret key" error will still appear if source is using previously generated public key for encryption. So, export and import, this will ensure that same key id is used for decryption and encryption.

    gpg --output gpg_pub_key --export 
    gpg --output gpg_sec_key --export-secret-keys 
    gpg --output gpg_sec_sub_key --export-secret-subkeys 
    
    gpg --import gpg_pub_key
    gpg --import gpg_sec_key
    gpg --import gpg_sec_sub_key
    

提交回复
热议问题