gpg decryption fails with no secret key error

后端 未结 9 658
一生所求
一生所求 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条回答
  •  無奈伤痛
    2020-12-13 18:22

    Following this procedure worked for me.

    To create gpg key. gpg --gen-key --homedir /etc/salt/gpgkeys

    export the public key, secret key, and secret subkey.

    gpg --homedir /etc/salt/gpgkeys --export test-key > pub.key
    gpg --homedir /etc/salt/gpgkeys --export-secret-keys test-key > sec.key
    gpg --homedir /etc/salt/gpgkeys --export-secret-subkeys test-key > sub.key
    

    Now import the keys using the following command.

    gpg --import pub.key
    gpg --import sec.key
    gpg --import sub.key
    

    Verify if the keys are imported.

    gpg --list-keys
    gpg --list-secret-keys
    

    Create a sample file.

    echo "hahaha" > a.txt

    Encrypt the file using the imported key

    gpg --encrypt --sign --armor -r test-key a.txt

    To decrypt the file, use the following command.

    gpg --decrypt a.txt.asc

提交回复
热议问题