Bootstrap FreeKB - GPG (GNU Privacy Guard) - Sign a file using GPG
GPG (GNU Privacy Guard) - Sign a file using GPG

Updated:   |  GPG (GNU Privacy Guard) articles

Let's say you want to create a digital signature of /tmp/foo.txt using GPG. The gpg command with the --sign flag can be used to digitally sign foo.txt. You will be prompted to provide a passphrase.

gpg --sign /tmp/foo.txt

 

Now there should be two files, the original file and the GPG encrypted file.

~]# ll /tmp
-rw-r--r-- 1 root root 12 Aug 14 13:38 foo.txt
-rw-r--r-- 1 root root 89 Aug 14 13:39 foo.txt.gpg

 

The --verify flag can be used to determine if foo.txt.gpg has been signed. Notice in this example the "good signature" is returned.

~]# gpg --verify /tmp/foo.txt.gpg
gpg: Signature made Sun 15 Aug 2021 05:39:27 AM CDT
gpg:                using RSA key 6144240CC1574477CC6DB78880FFFAE61599470D
gpg: Good signature from "John Doe <john.doe@example.com>" [ultimate]

 


Output file name

By default, the GPG encrypted file will be the original file name with the .gpg extension. The --output option can be used to define the name of the GPG encrypted file. In this example, the GPG encrypted file will be /tmp/bar.txt.gpg.

gpg --sign --output /tmp/bar.txt.gpg /tmp/foo.txt

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ca2b55 in the box below so that we can be sure you are a human.