GPG is based on the idea of two keys per person. Each person has a private key and a public key. The public key can decrypt something that was encrypted with the private key. To send a file securely, you encrypt it with your private key and the recipient’s public key. To decrypt the file, the recipient needs his private key and your public key.
From this you can see that public keys must be shared. You need the recipient’s public key to encrypt the file, and the recipient needs your public key to decrypt it. There is no danger in simply making your public keys public. There are even public key servers for this purpose, as we will see. Private keys must be kept secret. If your public key is public, then your private key must be kept secret and secure. We have mentioned steps below to Use GnuPG to Encrypt Files on Linux
Steps to Use GnuPG to Encrypt Files on Linux
$ sudo apt-get install gnupg
$ sudo yum install gnupg
Fedora Linux install gnupg
$ sudo dnf install gnupg
$ sudo pacman -S gnupg
$ sudo zypper install gpg2
# cd /usr/ports/security/gnupg/ && make install clean
# pkg install gnupg
$ doas pkg_add gnupg
Final Words
So here we conclude our article on how to Use GnuPG to Encrypt Files on Linux. Or you may use the tried-and-true GnuPG to encrypt a single file or folder. You can encrypt a file or folder with the gpg command such that a password is required to decrypt it. I’ll demonstrate how to fast encrypt a file using the gpg command.