gpg decrypt file fails: No secret key
by Sum1 from LinuxQuestions.org on (#54EQ8)
1. Digitalocean cloud-based CentOS7 machine using (GnuPG) 2.0.22 encrypts a file:
Code:gpg -e --passphrase-file /home/abc/phrase.txt --batch -r john@johnsmith.com /home/abc/somefile.tar.gz2. The public key on the cloud-based CentOS7 is then exported:
Code:gpg --output public.gpg --armor --export john@johnsmith.com3. The encrypted file, the pass-phrase file, and public key is then obtained and imported on Local Fedora 32 machine:
Code:scp john@cloud-centos7:/home/abc/phrase.txt /home/johnCode:scp john@cloud-centos7:/home/abc/somefile.tar.gz.gpg /home/johnCode:scp john@cloud-centos7:/home/abc/public.gpg /home/johnCode:gpg --import public.gpg4. Attempts to decrypt the file using the passphrase file and without it fail:
Code:gpg --passphrase-file /home/john/phrase.txt --batch -d --output /home/john/somefile.tar.gz /home/john/somefile.tar.gz.gpg
gpg: encrypted with 2048-bit RSA key, ID XXXXXXXXXXXXXXXXXX, created 2019-11-23
"john smith <john@johnsmith.com>"
gpg: decryption failed: No secret key
[mhf@zxc ~]$ gpg -d --output /home/john/somefile.tar.gz /home/john/somefile.tar.gz.gpg
gpg: encrypted with 2048-bit RSA key, ID XXXXXXXXXXXXXXXXXX, created 2019-11-23
"john smith <john@johnsmith.com>"
gpg: decryption failed: No secret keyI cannot determine why the imported gpg public key won't work and why gpg complains that a secret key is needed.
Thank you for reading.


Code:gpg -e --passphrase-file /home/abc/phrase.txt --batch -r john@johnsmith.com /home/abc/somefile.tar.gz2. The public key on the cloud-based CentOS7 is then exported:
Code:gpg --output public.gpg --armor --export john@johnsmith.com3. The encrypted file, the pass-phrase file, and public key is then obtained and imported on Local Fedora 32 machine:
Code:scp john@cloud-centos7:/home/abc/phrase.txt /home/johnCode:scp john@cloud-centos7:/home/abc/somefile.tar.gz.gpg /home/johnCode:scp john@cloud-centos7:/home/abc/public.gpg /home/johnCode:gpg --import public.gpg4. Attempts to decrypt the file using the passphrase file and without it fail:
Code:gpg --passphrase-file /home/john/phrase.txt --batch -d --output /home/john/somefile.tar.gz /home/john/somefile.tar.gz.gpg
gpg: encrypted with 2048-bit RSA key, ID XXXXXXXXXXXXXXXXXX, created 2019-11-23
"john smith <john@johnsmith.com>"
gpg: decryption failed: No secret key
[mhf@zxc ~]$ gpg -d --output /home/john/somefile.tar.gz /home/john/somefile.tar.gz.gpg
gpg: encrypted with 2048-bit RSA key, ID XXXXXXXXXXXXXXXXXX, created 2019-11-23
"john smith <john@johnsmith.com>"
gpg: decryption failed: No secret keyI cannot determine why the imported gpg public key won't work and why gpg complains that a secret key is needed.
Thank you for reading.