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
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