{"id":2433,"date":"2023-03-12T18:41:00","date_gmt":"2023-03-12T13:11:00","guid":{"rendered":"https:\/\/smarttech101.com\/?p=2433"},"modified":"2023-03-12T18:41:05","modified_gmt":"2023-03-12T13:11:05","slug":"how-to-encrypt-and-sign-your-files-using-gpg","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/","title":{"rendered":"How to encrypt and Sign your files using GPG"},"content":{"rendered":"\n<p>GPG is used to encrypt and sign a file. In gpg, we have a key pair. Each key pair has one public and one secret (also known as private) key. <\/p>\n\n\n\n<p><strong>Encryption<\/strong>: Public key is used to encrypt a message\/file. Now, to decrypt the encrypted message\/file, we need the corresponding private key. For example, Bob encrypts a massage\/file meant for Alice using Alice&#8217;s public key; now Alice can open it using her private key.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"489\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/Public_key_encryption.svg_.png?resize=500%2C489&#038;ssl=1\" alt=\"public key encryption\" class=\"wp-image-2447\"\/><figcaption class=\"wp-element-caption\">Asymmetric encryption using gpg (source: Wikimedia)<\/figcaption><\/figure>\n\n\n\n<p><strong>Signature: <\/strong>One can use his\/her private key to sign a message\/file. Now, another person can use the corresponding public key to verify the massage. For example, Alice signs a message with her private key. Using Alice&#8217;s public key,&nbsp;Bob can verify&nbsp;that Alice sent the message and&nbsp;that the message has not been modified.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"489\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/Private_key_signing.svg_.png?resize=500%2C489&#038;ssl=1\" alt=\"signature in gpg\" class=\"wp-image-2448\"\/><figcaption class=\"wp-element-caption\">Signature in gpg (source: Wikimedia)<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#benefits_of_gpg\">Benefits of GPG<\/a><\/li>\n\n\n\n<li><a href=\"#installation_of_gpg\">Installation of GPG<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#linux\">Linux<\/a><\/li>\n\n\n\n<li><a href=\"#windows\">Windows<\/a><\/li>\n\n\n\n<li><a href=\"#mac_os\">Mac OS<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#gpg_home_directory_and_its_configuration\">GPG home directory and its configuration<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#gpg_configuration_files\">GPG Configuration files<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#how_to_create_a_key_pair_in_gpg\">How to create a key pair in gpg<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_list_your_keys\">How to list your keys<\/a><\/li>\n\n\n\n<li><a href=\"#what_are_gpg_keyid_secret_public_master_and_subordinate_keys_user_id_fingerprint_etc\">What are gpg keyid, secret, public, master and subordinate keys, user id, fingerprint, etc?<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#gpg_keyid\">GPG Keyid<\/a><\/li>\n\n\n\n<li><a href=\"#gpg_public_and_secret_keys\">GPG Public and Secret Keys<\/a><\/li>\n\n\n\n<li><a href=\"#gpg_fingerprints\">GPG Fingerprints<\/a><\/li>\n\n\n\n<li><a href=\"#userid_in_gpg\">Userid in GPG<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#how_to_encrypt_a_file_using_gpg\">How to encrypt a file using gpg<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_decrypt_a_file_using_gpg\">How to decrypt a file using gpg<\/a><\/li>\n\n\n\n<li><a href=\"#symmetric_encryption_in_gpg\">Symmetric encryption in gpg<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#encryptingdecrypting_a_directory\">Encrypting\/decrypting a directory<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#how_to_export_a_public_key_in_gpg\">How to export a public key in gpg<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_import_a_public_key_in_gpg\">How to import a public key in gpg<\/a><\/li>\n\n\n\n<li><a href=\"#what_is_gpg_keyserver\">What is gpg keyserver<\/a><\/li>\n\n\n\n<li><a href=\"#import_a_public_key_from_the_keyserver\">Import a public key from the keyserver<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_send_keys_to_the_keyserver\">How to send keys to the keyserver<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_import_the_secret_key\">How to import the secret key<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_export_your_secret_key\">How to export your secret key<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_backup_gpg\">How to backup gpg<\/a><\/li>\n\n\n\n<li><a href=\"#signatures_in_gpg\">Signatures in GPG<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#how_to_create_signatures_in_gpg\">How to create signatures in GPG<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_verify_a_file_using_\">How to verify a file using GPG<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#how_to_get_the_printable_output_from_gpg\">How to get the printable output from gpg<\/a><\/li>\n\n\n\n<li><a href=\"#revocation_certificates_in_gpg\">Revocation Certificates in GPG<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#what_are_revocation_certificates\">What are revocation certificates<\/a><\/li>\n\n\n\n<li><a href=\"#creations_of_revocation_certificates\">Creations of revocation certificates<\/a><\/li>\n\n\n\n<li><a href=\"#revocation_of_a_key\">Revocation of a key<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#changing_expiration_date_passphrase_etc_in_gpg\">Changing expiration date, passphrase, etc. in gpg<\/a><\/li>\n\n\n\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits_of_gpg\">Benefits of GPG<\/h2>\n\n\n\n<p>Many Linux distributions are distributed over torrents. They ensure their safety by digitally signing their distribution. You might always notice a <code>*.sig<\/code> file along with your file <code>*.iso<\/code>. This <code>*.sig<\/code> file is used to verify that the <code>*.iso<\/code> file has not been changed.<\/p>\n\n\n\n<p>Many password managers (ex PASS) use GPG to store your passwords in encrypted forms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation_of_gpg\">Installation of GPG<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"linux\">Linux<\/h3>\n\n\n\n<p>By default, gpg2 is already installed in most Linux distributions. If it is not pre-installed, just install it from your official repository. It is highly likely you will find such a famous package. But if you don&#8217;t find it there, install it manually. First, download the file(s) GnuPG\u00a0(LTS) or GnuPG from <a href=\"https:\/\/www.gnupg.org\/(en)\/download\/index.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">GPG Download Page<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ tar jxf &lt;gnupg_tar.bz2&gt;\n$ cd &lt;gnupg_tar_dir&gt;\n<span style=\"text-decoration: underline;\">$ .\/configure\n$ make\n$ sudo make install<\/span><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"windows\">Windows<\/h3>\n\n\n\n<p>Download the installer from the <a href=\"https:\/\/www.gnupg.org\/(en)\/download\/index.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">GPG Download page<\/a>. Run the installer. Add the GPG in Windows&#8217; PATH. Now, you can run gpg from Windows CMD. <\/p>\n\n\n\n<p>Or Use Chocolatey:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>choco install gnupg<\/code><\/pre>\n\n\n\n<p>In this article, I will mainly talk about Linux (Unix) based systems. For windows, these commands have not been tested but they should work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mac_os\">Mac OS<\/h3>\n\n\n\n<p>Use Homebrew.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"gpg_home_directory_and_its_configuration\">GPG home directory and its configuration<\/h2>\n\n\n\n<p>GPG, by default, uses <code>~\/.gnupg<\/code> for storing its keys and configuration. Or set the environment variable <code>$GNUPGHOME<\/code> to overwrite the default behavior. Or use <code>--homedir<\/code> to\u00a0use your_path instead of <code>~\/.gnupg<\/code> or <code>$GNUPGHOME<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --homedir &lt;your_path&gt;<\/code><\/pre>\n\n\n\n<p>By default, GPG uses permissions 700 (<code>rwx------<\/code>) and 600 (<code>rw-------<\/code>) on directories and files respectively. If there are other permissions, it warns you, but it does not give any errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"gpg_configuration_files\">GPG configuration files<\/h3>\n\n\n\n<p>GPG sets its configuration from <code>gpg_home_dir\/{gpg.conf,dirmngr.conf,...}<\/code> and <code>\/etc\/gnupg\/{gpg.conf,dirmngr.conf}<\/code>. For example, If you use the flags <code>--no-default-keyring --keyring keyring-path<\/code> with gpg commands all the time, you can just put them in <code>gpg.conf<\/code>. Now no need to supply these flags anymore.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>no-default-keyring\nkeyring keyring-path<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_create_a_key_pair_in_gpg\">How to create a key pair in gpg<\/h2>\n\n\n\n<p>To generate a key pair, use the following command. It will guide you to set up the key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --full-gen-key<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg (GnuPG) 2.2.41; Copyright (C) 2022 g10 Code GmbH\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nPlease select what kind of key you want:\n   (1) RSA and RSA (default)\n   (2) DSA and Elgamal\n   (3) DSA (sign only)\n   (4) RSA (sign only)\n  (14) Existing key from card\nYour selection? 1\nRSA keys may be between 1024 and 4096 bits long.\nWhat keysize do you want? (3072) 3072\nRequested keysize is 3072 bits\nPlease specify how long the key should be valid.\n         0 = key does not expire\n      &lt;n&gt;  = key expires in n days\n      &lt;n&gt;w = key expires in n weeks\n      &lt;n&gt;m = key expires in n months\n      &lt;n&gt;y = key expires in n years\nKey is valid for? (0) 3w\nKey expires at Sat 01 Apr 2023 06:03:44 PM IST\nIs this correct? (y\/N) y\n\nGnuPG needs to construct a user ID to identify your key.\n\nReal name: Test12345\nEmail address: test12345@gmail.com\nComment: just kidding\nYou selected this USER-ID:\n    \"Test12345 (just kidding) &lt;test12345@gmail.com&gt;\"\n\nChange (N)ame, (C)omment, (E)mail or (O)kay\/(Q)uit? O\nWe need to generate a lot of random bytes. It is a good idea to perform\nsome other action (type on the keyboard, move the mouse, utilize the\ndisks) during the prime generation; this gives the random number\ngenerator a better chance to gain enough entropy.\nWe need to generate a lot of random bytes. It is a good idea to perform\nsome other action (type on the keyboard, move the mouse, utilize the\ndisks) during the prime generation; this gives the random number\ngenerator a better chance to gain enough entropy.\ngpg: revocation certificate stored as '\/home\/ajay\/.gnupg\/openpgp-revocs.d\/090070A730217F1FAC03E7A5D2571362EB8B21F2.rev'\npublic and secret key created and signed.\n\npub   rsa3072 2023-03-11 &#91;SC] &#91;expires: 2023-04-01]\n      090070A730217F1FAC03E7A5D2571362EB8B21F2\nuid                      Test12345 (just kidding) &lt;test12345@gmail.com&gt;\nsub   rsa3072 2023-03-11 &#91;E] &#91;expires: 2023-04-01]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_list_your_keys\">How to list your keys<\/h2>\n\n\n\n<p>To list public keys present in your computer, use <code>--list-keys<\/code> or <code>--list-public-keys<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-public-keys<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg: checking the trustdb\ngpg: marginals needed: 3  completes needed: 1  trust model: pgp\ngpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072 2023-02-17 [SC]\n      <span style=\"text-decoration: underline;\">03894010F347890A123DF87ABA7C45B7108F0083<\/span>\nuid           [ultimate] Ajay Yadav &lt;xyx1@gmail.com&gt;\nsub   rsa3072 2023-02-17 [E]\n\npub   rsa3072 2023-02-17 [SC]\n      <span style=\"text-decoration: underline;\">91D335983408E555CFDC47D77F192C20064C28D5<\/span>\nuid           [ultimate] unblocked8888 &lt;xyx2@gmail.com&gt;\nsub   rsa3072 2023-02-17 [E]<\/pre>\n\n\n\n<p>To list secret keys present in your computer, use <code>--list-secret-keys<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-secret-keys<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\nsec   rsa3072 2023-02-17 &#91;SC]\n      <span style=\"text-decoration: underline;\">03894010F347890A123DF87ABA7C45B7108F0083<\/span>\nuid           &#91;ultimate] Ajay Yadav &lt;xyx1@gmail.com&gt;\nssb   rsa3072 2023-02-17 &#91;E]\n\nsec   rsa3072 2023-02-17 &#91;SC]\n      <span style=\"text-decoration: underline;\">91D335983408E555CFDC47D77F192C20064C28D5<\/span>\nuid           &#91;ultimate] unblocked8888 &lt;xyx2@gmail.com&gt;\nssb   rsa3072 2023-02-17 &#91;E]<\/code><\/pre>\n\n\n\n<p>Abbreviations used in the above outputs:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>pub: public<\/li>\n\n\n\n<li>sec: secret<\/li>\n\n\n\n<li>sub or ssb: subordinate keys<\/li>\n\n\n\n<li>uid: user id<\/li>\n<\/ol>\n\n\n\n<p><strong>Note<\/strong>: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the above outputs, there are two keyids (respective fingerprints are underlined). Each keyid has one public, one secret key, and one user id. <\/li>\n\n\n\n<li>item in &lt;&gt; is the email id you had entered in the <code>gpg --full-gen-key<\/code><\/li>\n\n\n\n<li>You can use <code>--keyid-format &lt;short|long|0xshort|0xlong&gt;<\/code> to print the keyid as well in the desired format.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-keys --keyid-format short\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072\/<span style=\"text-decoration: underline;\">108F0083<\/span> 2023-02-17 &#91;SC]\n      03894010F347890A123DF87ABA7C45B7108F0083\nuid         &#91;ultimate] Ajay Yadav &lt;xyx1@gmail.com&gt;\nsub   rsa3072\/<span style=\"text-decoration: underline;\">5814BF83<\/span> 2023-02-17 &#91;E]\n\n$ gpg --list-keys --keyid-format long\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072\/<span style=\"text-decoration: underline;\">BA7C45B7108F0083<\/span> 2023-02-17 &#91;SC]\n      03894010F347890A123DF87ABA7C45B7108F0083\nuid                 &#91;ultimate] Ajay Yadav &lt;xyx1@gmail.com&gt;\nsub   rsa3072\/<span style=\"text-decoration: underline;\">79BA29CC5814BF83<\/span> 2023-02-17 &#91;E]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what_are_gpg_keyid_secret_public_master_and_subordinate_keys_user_id_fingerprint_etc\">What are gpg keyid, secret, public, master and subordinate keys, user id, fingerprint, etc?<\/h2>\n\n\n\n<p>Observer the following output.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-public-keys --fingerprint --with-subkey-fingerprints --keyid-format 0xlong\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072\/0x7F192C20064C28D5 2023-02-17 &#91;SC]\n      Key fingerprint = 91D3 3598 3408 E555 CFDC  47D7 7F19 2C20 064C 28D5\nuid                   &#91;ultimate] unblocked8888 (comment goes into the bracket) &lt;xyx2@gmail.com&gt;\nsub   rsa3072\/0x459DA250EC6F3071 2023-02-17 &#91;E]\n      Key fingerprint = CC16 7002 5FA5 C884 0385  B4E9 459D A250 EC6F 3071<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$  gpg --list-secret-keys --fingerprint --with-subkey-fingerprints --keyid-format 0xlong \nsec   rsa3072\/0x7F192C20064C28D5 2023-02-17 &#91;SC]\n      Key fingerprint = 91D3 3598 3408 E555 CFDC  47D7 7F19 2C20 064C 28D5\nuid                   &#91;ultimate] unblocked8888 (comment goes into the bracket) &lt;xyx2@gmail.com&gt;\nssb   rsa3072\/0x459DA250EC6F3071 2023-02-17 &#91;E]\n      Key fingerprint = CC16 7002 5FA5 C884 0385  B4E9 459D A250 EC6F 3071<\/code><\/pre>\n\n\n\n<p>Here, <code>rsa<\/code> is the key&#8217;s type and 3072 is the key&#8217;s bit length. The values shown in the above output were set by you during the generation of the key using <code>--full-gen-key<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"gpg_keyid\">GPG keyid<\/h3>\n\n\n\n<p>The first word <code>0x...<\/code> is the primary key and the second word <code>0x...<\/code> is the subordinate key. <code>0x<\/code> tells that the keys are in a hexagonal format. Therefore the keyids are <code>7F192C20064C28D5<\/code> and <code>459DA250EC6F3071<\/code> in the above output. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"gpg_public_and_secret_keys\">GPG Public and Secret Keys<\/h3>\n\n\n\n<p>The public key has two parts &#8211; one master public key and one subordinate public key. The first two lines in the above output are corresponding to the master public key and the bottom two lines are corresponding to the subordinate public key. Similarly, The secret key has two parts &#8211; one master secret key and one subordinate secret key. <\/p>\n\n\n\n<p>In this article, <strong>I will mainly talk about the master keys<\/strong>.<\/p>\n\n\n\n<p>You should never share your secret keys with anyone. But you can share the public keys with anybody. Therefore, you will easily find the public key from all over the internet.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"gpg_fingerprints\">GPG Fingerprints<\/h3>\n\n\n\n<p>There are two fingerprints mentioned in the above output. The first one is for the public master key and the second one is for the public subordinate key. Since you get the public key from the internet, you need to verify your fingerprint as well. For that, you need to contact the key owner directly, or through mail\/internet and ask about their fingerprint. And then match with the above command&#8217;s result.<\/p>\n\n\n\n<p>For corresponding secret keys, they are the same.<\/p>\n\n\n\n<p>Notice some common letters in keyid and fingerprint (for example, <code>7F192C20064C28D5<\/code> and <code>91D3 3598 3408 E555 CFDC  47D7 <span style=\"text-decoration: underline;\">7F19 2C20 064C 28D5<\/span><\/code>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"userid_in_gpg\">Userid in GPG<\/h3>\n\n\n\n<p><code>unblocked8888 (comment goes into the bracket) &lt;xyx2@gmail.com><\/code> is your user-id. During the generation of the key (recall <code>--full-gen-key<\/code>), you might have used some comment which goes into the bracket.<\/p>\n\n\n\n<p>In any command, you need to use the key identifier:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg &lt;your_options&gt; &lt;key-identifier&gt;<\/code><\/pre>\n\n\n\n<p>Here, &lt;key-identifier> is the key ID, fingerprint, user-id, or part of it, etc. GPG is quite flexible in this regard. ZSH&#8217;s autocompletion also works here.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_encrypt_a_file_using_gpg\">How to encrypt a file using gpg<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg -r xyx@gmail.com -e your_file.txt<\/code><\/pre>\n\n\n\n<p><code>-r<\/code> or <code>--recipient<\/code> is used to specify the user to encrypt. <code>-e<\/code> or <code>--encrypt<\/code> is for encryption. Now, a file called <code>your_file.txt.gpg<\/code> will be generated. <\/p>\n\n\n\n<p>Only the people with a secret key corresponding to the user <code>xyx@gmail.com<\/code> will be able to open it. But you only need the public key of the user <code>xyx@gmail.com<\/code> to encrypt the file. Because of involving two different keys, it is called &#8216;asymmetric cryptography&#8217;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_decrypt_a_file_using_gpg\">How to decrypt a file using gpg<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg -d your_file.txt.gpg<\/code><\/pre>\n\n\n\n<p><code>-d<\/code> or <code>--decrypt<\/code> is used to decrypt the given file. Please note that you don&#8217;t need to specify the username here. gpg will pick up that from the <code>*.gpg<\/code> file. Now you need to input the passphrase corresponding to this user id.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"symmetric_encryption_in_gpg\">Symmetric encryption in gpg<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --symmetric doc<\/code><\/pre>\n\n\n\n<p>It generates <code>doc.gpg<\/code>. Here, no key pair is needed i.e. even if you have not generated any key using <code>gpg --full-gen-key<\/code>, you can use this command. It will ask for a passphrase using which this file will be encrypted.<\/p>\n\n\n\n<p><strong>Note<\/strong>: a more robust command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --symmetric --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 --s2k-count 65536 doc<\/code><\/pre>\n\n\n\n<p>Here,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It uses the AES256 (default: AES128)<\/li>\n\n\n\n<li>&#8220;Uses the SHA-512 digest algorithm to mangle the passphrase and generate the encryption key&#8221;<\/li>\n\n\n\n<li>&#8220;Mangles the passphrase for 65536 iterations&#8221;<\/li>\n\n\n\n<li>To find all of the available options, use <code>--version<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --version\ngpg (GnuPG) 2.2.40\nlibgcrypt 1.10.1-unknown\nCopyright (C) 2022 g10 Code GmbH\nLicense GNU GPL-3.0-or-later &lt;https:\/\/gnu.org\/licenses\/gpl.html&gt;\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nHome: \/home\/ajay\/.gnupg\nSupported algorithms:\nPubkey: <span style=\"text-decoration: underline;\">RSA<\/span>, ELG, DSA, ECDH, ECDSA, EDDSA\nCipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, <span style=\"text-decoration: underline;\">AES256<\/span>, TWOFISH,\n        CAMELLIA128, CAMELLIA192, CAMELLIA256\nHash: SHA1, RIPEMD160, SHA256, SHA384, <span style=\"text-decoration: underline;\">SHA512<\/span>, SHA224\nCompression: Uncompressed, <span style=\"text-decoration: underline;\">ZIP<\/span>, ZLIB, BZIP2<\/code><\/pre>\n\n\n\n<p>To decrypt <code>doc.gpg<\/code>, use <code>--decrypt<\/code> or <code>-d<\/code>. Input the passphrase you used to encrypt the file. You can decrypt it on another computer. There is no need for a private or public key on that computer. Just use the passphrase.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg -d doc.gpg<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"encryptingdecrypting_a_directory\">Encrypting\/decrypting a directory<\/h3>\n\n\n\n<p>Use <code>gpgtar<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpgtar --symmetric --output dir.gpg dir<\/code><\/pre>\n\n\n\n<p>To decrypt it, use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpgtar -d dir.gpg<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_export_a_public_key_in_gpg\">How to export a public key in gpg<\/h2>\n\n\n\n<p>To export the public key, use <code>--export<\/code> flag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --export --output public-key.gpg xyx1@gmail.com <\/code><\/pre>\n\n\n\n<p>Now, you can email it to your friend&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_import_a_public_key_in_gpg\">How to import a public key in gpg<\/h2>\n\n\n\n<p>To import anyone&#8217;s public key, you need to have the file public-key file. Contact the person or download it from their website. Then use <code>--import<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --import public-key.asc<\/code><\/pre>\n\n\n\n<p>Now, when you list the public key, you will have one more key in your list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-public-keys<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg: checking the trustdb\ngpg: marginals needed: 3  completes needed: 1  trust model: pgp\ngpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072 2023-02-17 &#91;SC]\n      <span style=\"text-decoration: underline;\">03894010F347890A123DF87ABA7C45B7108F0083<\/span>\nuid           &#91;ultimate] Ajay Yadav &lt;xyx1@gmail.com&gt;\nsub   rsa3072 2023-02-17 &#91;E]\n\npub   rsa3072 2023-02-17 &#91;SC]\n      <span style=\"text-decoration: underline;\">91D335983408E555CFDC47D77F192C20064C28D5<\/span>\nuid           &#91;ultimate] unblocked8888 &lt;xyx2@gmail.com&gt;\nsub   rsa3072 2023-02-17 &#91;E]\n\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072 2023-02-16 &#91;SC]\n      <span style=\"text-decoration: underline;\">28C1E1C8A559745FA162B7AE83873602785B519E<\/span>\nuid           &#91;ultimate] test123 (test) &lt;test@gmail.com&gt;\nsub   rsa3072 2023-02-16 &#91;E]<\/code><\/pre>\n\n\n\n<p>Now, you can use <code>gpg -r test@gmail.com -e your_file.text to encrypt it; only the user test@gmail.com<\/code> will be able to open the encrypted file, not even the user who encrypted it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what_is_gpg_keyserver\">What is gpg keyserver<\/h2>\n\n\n\n<p>Keyservers are the servers used to distribute public keys. Anybody can upload and download keys from it. Some of them require you to verify your email as well. But be aware that sharing emails might promote spam in your inbox. Some allow you to delete your keys and some don&#8217;t.<\/p>\n\n\n\n<p>Ex &#8211;&nbsp;<a href=\"https:\/\/keys.openpgp.org\/\">https:\/\/keys.openpgp.org\/<\/a>;&nbsp;<a href=\"https:\/\/keys.mailvelope.com\/\">https:\/\/keys.mailvelope.com\/<\/a>;&nbsp;<a href=\"https:\/\/keyserver.ubuntu.com\/\">https:\/\/keyserver.ubuntu.com\/<\/a><\/p>\n\n\n\n<p>Most of the distributions\/OSes use a default keyserver (for example, https:\/\/162.213.33.9:443 in Arch Linux). But you can use a desired key server instead of the default one using <code>--keyserver<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --keyserver hkps:\/\/keys.openpgp.org\/ &lt;further_arguments&gt;<\/code><\/pre>\n\n\n\n<p>Or, put this in the file <code>~\/.gnupg\/dirmngr.conf<\/code> to use this server as default:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>keyserver hkps:\/\/keys.openpgp.org\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"import_a_public_key_from_the_keyserver\">Import a public key from the keyserver<\/h2>\n\n\n\n<p>If you don&#8217;t have the public key file, you can use the keyserver. In fact, it is the standard method. <\/p>\n\n\n\n<p>Use <code>--search-keys<\/code> flag to search for a key. You can use <code>uid<\/code> or a part of it to search for the key.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --search-keys &lt;user-id&gt; <\/code><\/pre>\n\n\n\n<p>For example,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --search-keys test\ngpg: data source: https:\/\/162.213.33.9:443\n(1)    test pc &lt;test@rothlin.com&gt;\n      2048 bit RSA key A3D3149FC9D7CC40, created: 2009-12-12\n(2)      2048 bit RSA key 75C686106C62E780, created: 2015-04-24\n(3)    Detlev Grothe (test hat nichts mit pgp schl\u00fcssel gemein) &lt;detlev.grot\n      1024 bit DSA key DBABBE316E4E75B0, created: 2005-01-30\n(4)    test-key (Testing) &lt;info@dldh.hu&gt;\n      1024 bit RSA key FF80AA9F73A90A01, created: 2010-09-08\n(5)    kjloh (test) &lt;kjloh71@gmail.com&gt;\n      1024 bit DSA key 1605D441D52DAF01, created: 2006-08-28\n(6)    test &lt;pavlo.shevchuk@vgs.io&gt;\n      4096 bit RSA key D9DCE17365815641, created: 2018-10-10\n(7)    Parker Gibson (Test RSA Key) &lt;rsa@pgibson.org&gt;\n      4096 bit RSA key 2B9ED50EBA8CFA02, created: 2010-12-13\n(8)      2048 bit RSA key B00B355090F1BE02, created: 2017-01-28\n(9)    filipe motta (teste) &lt;filipemotta@gmail.com&gt;\n      1024 bit DSA key F583CD78566B9612, created: 2009-10-03\n(10)      2048 bit RSA key DB094661B3D74D32, created: 2018-05-29\n(11)      1024 bit DSA key 71751E0256925AB2, created: 2014-11-07\n(12)      1024 bit DSA key 2C285BA3F3EFBDB2, created: 2013-10-10\n(13)    kiran (test cetrificate) &lt;kiran.sp@gmail.com&gt;\n      2048 bit RSA key 826357A9B74F9FF2, created: 2014-12-15\n(14)    alice (lab test) &lt;101430613@host.local&gt;\n      1024 bit RSA key E5BB325A8412CC13, created: 2011-09-09\nKeys 1-14 of 100 for \"test\".  Enter number(s), N)ext, or Q)uit &gt;<\/code><\/pre>\n\n\n\n<p>Just enter the corresponding number as given in the output and you are done.<\/p>\n\n\n\n<p>Or, you can directly import the public key without searching for it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --recv-keys key-id<\/code><\/pre>\n\n\n\n<p>But make sure that you use full key-id  (for example, <code>BA7C45B7108F0083<\/code> instead of 108F0083) otherwise, you might end up importing other people&#8217;s keys as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_send_keys_to_the_keyserver\">How to send keys to the keyserver<\/h2>\n\n\n\n<p>Use <code>--send-keys<\/code> to send keys to the default keyserver.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --send-keys &lt;key-id&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_import_the_secret_key\">How to import the secret key<\/h2>\n\n\n\n<p>The same command <code>gpg --import secret-key.asc<\/code> also imports the secret key. But you will need the passphrase corresponding to the secret key. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_export_your_secret_key\">How to export your secret key<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --export-secret-keys --armor --output private-key.asc &lt;key-identifier&gt;<\/code><\/pre>\n\n\n\n<p>Unlike <code>--export<\/code>, it asks for a passphrase; during <code>--import private-key.asc<\/code>, it again asks for the passphrase.<\/p>\n\n\n\n<p>It is also recommended to put symmetric encryption on <code>private-key.asc<\/code> so that nobody knows the content of the file (<code>-----BEGIN PGP PRIVATE KEY BLOCK-----...<\/code>). For more info, see <a href=\"https:\/\/web.archive.org\/web\/20210803213236\/https:\/\/habd.as\/post\/moving-gpg-keys-privately\/\" target=\"_blank\" rel=\"noreferrer noopener\">Moving GPG Keys Privately<\/a>.<\/p>\n\n\n\n<p>By the way, the output file <code>private-key.asc<\/code> also includes the corresponding public keys as well. So when you import this secret key, the corresponding public key is imported as well.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --import private-key.asc\ngpg: directory '\/home\/ajay\/.gnupg' created\ngpg: keybox '\/home\/ajay\/.gnupg\/pubring.kbx' created\ngpg: \/home\/ajay\/.gnupg\/trustdb.gpg: trustdb created\ngpg: key BA7C45B7108F0083: public key \"Ajay Yadav &lt;xyx1@gmail.com&gt;\" imported\n...\n...\n...<\/code><\/pre>\n\n\n\n<p>You can also use the packages <code>paperkey<\/code> and <code>qrencode<\/code> to export your secret keys in human-readable text format or machine-readable barcode respectively. Now, this can be backed up somewhere safe. <\/p>\n\n\n\n<p>The inclusion of the public key increases the file size. On the other hand, the package <code>paperkey<\/code> only exports the secret key thus reducing the file size (but I did not notice any significant reduction in the file size).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> gpg --export-secret-keys ajay | paperkey &gt; sec-paper.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_backup_gpg\">How to backup gpg<\/h2>\n\n\n\n<p>You can follow three methods:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>copy the directory <code>~\/.gnupg<\/code>: fastest and least secure.<\/li>\n\n\n\n<li><code>gpg --export-secret-keys key-identifier --output private-key.gpg<\/code>: both public and private keys are backed up.<\/li>\n\n\n\n<li>Secret key using <code>paperkey<\/code> and public key using key-server\/google-drive, etc.<\/li>\n<\/ol>\n\n\n\n<p>But in all of these methods, you need to remember\/backup your passphrase separately.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"signatures_in_gpg\">Signatures in GPG<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how_to_create_signatures_in_gpg\">How to create signatures in GPG<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --output file.sig --sign file<\/code><\/pre>\n\n\n\n<p>It creates a signature; now using the <code>file.sig<\/code> I can verify if the file has been tempered since it was last signed or not.<\/p>\n\n\n\n<p>Here, <code>file.sig<\/code> is not encrypted. It is only in the Binary format hence you can just use <code>gpg --decrypt file.sig<\/code> to read its content (no password will be asked). <\/p>\n\n\n\n<p>The <code>file.sig<\/code> contains both file as well signature. To get a separate signature, use <code>--detach-sig<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --output 10.pdf.sig --detach-sig 10.pdf<\/code><\/pre>\n\n\n\n<p>Here, <code>10.pdf.sig<\/code> only contains the signature part. It is most useful in distributing software, operating systems, etc. to verify that they have not been tampered with. On the other hand,  if I use <code>--sign<\/code>, the output <code>10.pdf.sig<\/code> will contain both signature as well 10.pdf; opening the pdf from 10.pdf.sig will be difficult.<\/p>\n\n\n\n<p>In the above command, <code>file.sig<\/code> is in binary format. To get the signature in human-readable format, use <code>--clearsign<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --output file.sig --clearsign file<\/code><\/pre>\n\n\n\n<p><strong>Note: <\/strong>In all of the above signing commands, the signing key is the &#8216;default key&#8217;. If the default key is not set, the first unrevoked key in the output <code>gpg --list-secret-keys<\/code> will be used as the default key or you can use <code>--default-key &lt;key-identifier><\/code> or <code>--local-user &lt;key-identifier><\/code> option to supply the key.<\/p>\n\n\n\n<p><strong>Note: <\/strong>You can put encryption on signed documents to bring another level of security.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how_to_verify_a_file_using_\">How to verify a file using GPG<\/h3>\n\n\n\n<p>Use <code>--verify<\/code> to verify the <code>file<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --verify file.sig<\/code><\/pre>\n\n\n\n<p>Now, look for <code>Good<\/code> or <code>Bad<\/code> in the output. If it is good, then you are good to go. Otherwise, your file has been modified since it has been created. <\/p>\n\n\n\n<p>If <code>file.sig<\/code> is created with <code>--detach-sig<\/code>, you need to put <code>file<\/code> in the same directory as well, or use full path instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --verify file.sig \/path\/to\/file<\/code><\/pre>\n\n\n\n<p><strong>Example<\/strong>: during the <a href=\"https:\/\/smarttech101.com\/how-to-install-arch-linux-and-support-graphics\/\" target=\"_blank\" rel=\"noreferrer noopener\">Arch Linux installation<\/a>, you should verify the signature. First, put the signature file (*.sig) and the iso file in the same directory. Now, use the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --keyserver=hkp:\/\/pool.sks-keyservers.net --keyserver-options auto-key-retrieve --verify archlinux-2020.08.01-x86_64.iso.sig<\/code><\/pre>\n\n\n\n<p>Now you will get something like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\ngpg: Signature made Wed 25 Jan 2023 04:50:45 PM IST\n...\ngpg: key 7F2D434B9741E8AC: public key \"Pierre Schmitz &lt;pierre@archlinux.de&gt;\" imported \n...\ngpg: <span style=\"text-decoration: underline;\">Good signature<\/span> from \"Pierre Schmitz &lt;pierre@archlinux.org&gt;\" &#91;unknown]\n...\nPrimary key fingerprint: 4AA4 767B BC9C 4B1D 18AE  28B7 7F2D 434B 9741 E8AC<\/code><\/pre>\n\n\n\n<p>In the result, match the above fingerprint with Pierre&#8217;s fingerprint given on his website (for this example, Arch Developers&#8217; website (<a href=\"https:\/\/www.archlinux.org\/people\/developers\/\">https:\/\/www.archlinux.org\/people\/developers\/<\/a>) for an additional level of verification.<\/p>\n\n\n\n<p><code>--keyserver-options auto-key-retrieve<\/code> will retrieve (import) the required key from the server when needed. You can use this in your configuration file by adding a line <code>keyserver-options auto-key-retrieve<\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_get_the_printable_output_from_gpg\">How to get the printable output from gpg<\/h2>\n\n\n\n<p>Use <code>--armor<\/code> with any of the gpg commands to get the output in ASCII. Ex- keys, encrypted documents, signatures, etc. Otherwise, it is in binary form. For example,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --export --armor --output public-key.asc xyx1@gmail.com<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cat public-key.asc\n-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQGNBGPvj\/0BDACXjqDT38XfhOJ1y47RZSwUyK+sLsdn6Hp5bL8kfFfWKgz0w99n\nNdkNAKPrm+b3QfPSDNM+bWf6Sz123OAikxFMGszZRagMj2kXhgjYR+vUL+2it0TJ\nYca40xMwbsjmJb\/BCRw2gW\/q+oMjxLqlvulU9yj0l6dfdfdfdryTAyw+Wsu\/J2\/6\nsKrmIbMoO3\/DkobIJ0zke1L6diBMAAKGHjDnO07oUZMRnqZKNlubBL5WMogHeT8K\nEoFBJ7PbzQpVaH4to\/xhGkYg6p+GW5iCj2E0Q1d+JxXEBwidYfbvqJJkYb05Gp0q\nuokVWxQZbna7ererdcxewr563#$asfdMDd8Cdz5OwXPrLJVNxwHlSJQ3PwHi0iaA\nE52G3iQIc95U5yAcNg7csDKsKaM9WGsHQpII2jwFG\/tk7H2XiAaK+fASsrLRnTih\n+qvhRgY785VhWI\/MAKvGLIWeD04RRPyuZ+hDyWsbYIoK4V8Kx3lYc1gWuV4xa\/uY\n\/DpRsVNRCRLxfL8AEQEAAbQkQWpheSBZYWRhdiA8eWFkYXZhamF5OTQ1MkBnbWFp\nbC5jb20+iQHOBBMBCAA4FiEEA4lAEPNHiQoSPfh6unxFtxCPAIMFAmPvj\/0CGwMF\nCwkIBdfdfscsxfewIGFQoJCAsCBBYCAwECHgECF4AACgkQunxFtxCPAIMPYQv\/Zt\nJB5mAViDXJf8mSz3LLpHNUbNtC+fTDd1BY7qro9tW0Nt+VEdUDP8S9NyK22Z6MAG\nU\/oHbHp4qVOSc5RRn1KBVDKpbuOFuuk\/cNBEKTMAd5YnOYBmo9wlxFRWwvdGFafH\nLjDxUv3d6m\/wj\/TSO5RQLGFwuQlXo\/zOT2ED9lJP0SZNYosWb\/QjZ2WIKfx\/uaLb\niZfmR6F6JmvNW6tukao6\/QNe4OGdrOBIad0fL0ace5CW3IBEiWZDjD1R\/wD\/D7o3\nl9ieefmsn5ADcA3tE2XLTI2H6lILt3InswLhG0SkLYUh9BC7cgKn5WkhKcvs\/Cdk\n1ilKYm+WfbWDz7gsmSfudfdfdfdfGSVMViPkTaEIcOQhQ0UuCAsF7+5qLzJKV0fR\nIv5Fsex5vXlyKxLmP+dV9VfXM+J4Xdax0w40G1yHPMv\/yUySFJU4FEYdSp7UkpTN\njao7pkfoMyfo2OKx6yQYPTWh0\/iKKeky6143Zc4fT5Ylpwb4zLP9uQGNBGPvj\/0B\nDADXbuWLeUkBJH5ibM4n5sc7bJhBmse0nnsJSu5+cIMgpi1FgZsdfdfdfdNDwfH4\ntCeg4JG7nBhCxx4lXppU5VUVOkjiFy4xX\/25Sreuh0GSFx0bbK4ecF2lbBGgXidh\n8y03ENDsn8hZ48XQIl9ChRdOhk54zWA2MJWL4T1wR21xPWSfLxcVPjHHCDYsVMAO\nCn5SeIeOxp1YqT8w9qPHCSVPM8B8rVxNMed+1kbS6ztO1HTVXZkp2frb3fmVeX84\nFmmz510CPZ7OX1Snb1GB1MxcrBBM7MyNUufiBQs+xd1uO\/VTQTV4M4JIqdvn\/Ja+\nlQAGo9eb974evCpOoQ6gxOFm4b7IOGupfJmilshp69QCRYwhoix\/5LtsNPNOOxQF\nqKQ6CsLsyhXMrPpXS7z\/IGXMTdfYNwZJMy6rulcACne94tG\/q6MF4gzbVeLoCFS8\ngTU\/Er5rSdbBn3qGxtsTlo3JZi0U62cElrmRTKj\/lhXqsb6b01THKtoKWlFyM0hT\n\/c0AEQEAAYkBtgQYAQgAIBYhBAOJQBDzR4kKEj34erp8RbcQjwCDBQJj74\/9AhsM\nAAoJELp8RbcQjwCDY20L\/3svQ8nG2gwXkRgWdqEiswzgJoFd+LwR1mg1ArPhELCB\nP3Rmd9Oe8nwYMqE6vWvq6MLMM1EIHKhCkvzZiM4rjAIAztDT1PgoFrc21PehHK62\new4G+d0yHbiTGG4uX2tjzsgtVhB5VdKPQRFeD1V\/0vcd\/Ym3DEPRdu3+WYt\/h6px\nGf8gAhdjCM6VP6c7mDS2CbS9MpM6cQsLB85j8fpqzGUe81PY0imW1hoZRTOu+yka\nR3VJM3YBV+QECLrGmiAtrmozkXeotVk74Ecfw32l7rIHAQgcb\/9KbjIrVSF+gyZt\n15drAph+F6EwR3zg67HVYtrK4i3vqDLZOKiEEUblXIDAHql\/fEsan36C9mPJMJ8l\nBmrcifl+w0AwVbcTFZ5FbSjLHWpJc5ZX1+gh\/H5B68rgpBcL7GobFalCafT2Vj7d\nlIHO639i2tMOuLPaLasijsNFbvWHcklFvgXFGxyZtN+MR2knQBmHnyeiood42rZg\nEAgtEFzX7sZhTbjPkV0HnQ==\n=MV80\n-----END PGP PUBLIC KEY BLOCK-----<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --export --output public-key.gpg xyx1@gmail.com<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\ufffd\ufffdc\ufffd\ufffd\n     \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u07c4\ufffdu\u02ce\ufffde,\u022f\ufffd.\ufffdg\ufffdzyl\ufffd$|W\ufffd*\n\ufffd\ufffd\ufffd\ufffdA\ufffd\ufffd                          \ufffd\ufffd\ufffdg5\ufffd\n       \ufffd&gt;mg\ufffdK=v\ufffd\ufffd\"\ufffdL\ufffd\ufffd\ufffdE\ufffd\n                         \ufffdi\ufffdG\ufffd\ufffd\/\ufffd\ufffd\ufffdD\ufffda\u01b8\ufffd0n\ufffd\ufffd%\ufffd\ufffd\t6\ufffdo\ufffd\ufffd\ufffd#\u013a\ufffd\ufffd\ufffdT\ufffd(\ufffd\ufffd\ufffd\ufffdL\n                                                                   \ufffd\ufffdk.\ufffd\ufffd\ufffd\ufffd\ufffd\n                                                                            \ufffdG|\ufffd\ufffd\ufffd!\ufffd(;\u00d2\ufffd\ufffd'L\ufffd{R\ufffdv L\ufffd0\ufffd;N\ufffdQ\ufffd\ufffd\ufffdJ6&#91;\ufffd\ufffdV2\ufffdy?\n\ufffdA'\ufffd\ufffd\ufffd\nUh~-\ufffd\ufffda\ufffdF \ua7c6&#91;\ufffd\ufffd\ufffda4CW~'\ufffda\ufffd\u6674da\ufffd9\ufffd\ufffd*\ufffd\ufffd\ufffdJ$UlPe\ufffd\ufffd\ufffdh\ufffd\\\ufffd\ufffd\ufffd's\ufffd\ufffd&gt;\ufffd\ufffdT\ufffdpT\ufffdCs\ufffd-\"h\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffds\ufffdT\ufffd 6\u07302\ufffd)\ufffd=XkB\ufffd&lt;d\ufffd}\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u045d8\ufffd\ufffd\ufffd\ufffdF;\ufffdaX\ufffd\ufffd\ufffd\ufffd,\ufffd\ufffdND\ufffd\ufffdg\ufffdC\ufffdk\ufffd\n\ufffd_\n\ufffdyXsX\ufffd^1k\ufffd\ufffd\ufffd:Q\ufffdSQ\t\ufffd|\ufffd\ufffd$Ajay Yadav &lt;xyx1@gmail.com&gt;\ufffd8!\ufffd@\ufffdG\ufffd\n=\ufffdz\ufffd|E\ufffd\ufffd\ufffdc\ufffd\ufffd\n...\n...<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"revocation_certificates_in_gpg\">Revocation Certificates in GPG<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what_are_revocation_certificates\">What are revocation certificates<\/h3>\n\n\n\n<p>Revocation certificates are used to revoke a\u00a0key when it\u00a0is ever lost or compromised. Revocation certificates are absolutely necessary. Create one and store it somewhere safe such as your safe deposit box. Prefer revocation to deletion of a key whenever your key is lost because the revoked key can still be used to decrypt and verify\u00a0old\u00a0data (files and signatures).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"creations_of_revocation_certificates\">Creations of revocation certificates<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --gen-revoke --armor --output revcert.asc &lt;key-identifier&gt;<\/code><\/pre>\n\n\n\n<p>However, revocation certificates are automatically generated for newly generated keys. Their filename&#8217;s format is <code>fingerprint.rev<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ls -1 \/home\/ajay\/.gnupg\/openpgp-revocs.d \n     \n03894010F347890A123DF87ABA7C45B7108F0083.rev\n91D335983408E555CFDC47D77F192C20064C28D5.rev<\/code><\/pre>\n\n\n\n<p>These are text files. You need to remove the extra colon in <code>:-----BEGIN PGP PUBLIC KEY BLOCK-----<\/code> from the file before using it. See the file for more info.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ cat '\/home\/ajay\/.gnupg\/openpgp-revocs.d\/91D335983408E555CFDC47D77F192C20064C28D5.rev'\nThis is a revocation certificate for the OpenPGP key:\n\npub   rsa3072 2023-02-17 &#91;S]\n      91D335983408E555CFDC47D77F192C20064C28D5\nuid          unblocked8888 &lt;xyx2@gmail.com>\n\nA revocation certificate is a kind of \"kill switch\" to publicly\ndeclare that a key shall not anymore be used.  It is not possible\nto retract such a revocation certificate once it has been published.\n\nUse it to revoke this key in case of a compromise or loss of\nthe secret key.  However, if the secret key is still accessible,\nit is better to generate a new revocation certificate and give\na reason for the revocation.  For details see the description of\nof the gpg command \"--generate-revocation\" in the GnuPG manual.\n\nTo avoid an accidental use of this file, a colon has been inserted\nbefore the 5 dashes below.  Remove this colon with a text editor\nbefore importing and publishing this revocation certificate.\n\n:-----BEGIN PGP PUBLIC KEY BLOCK-----\nComment: This is a revocation certificate\n\niQG2BCABCAAgFiEEkdM1mDQI5VXP3EfXfxksIAZMKNUFAmPvkDkCHQAACgkQfxks\nIAZMKNXungv+PaZMvDVQ1FSL5i1m3YJAlXT9WKHJ9KxpzzzQlkUDM7Et\/E1\/HVGI\nXIsMk+1ZREZIrULMm9wi0etoRrKZsvPrEy6cdd9WqZpf\/NqDC5GIVfmHsvvct47v\nby5d6ekxddfdsfaeccxeedfsrgYUyhehemncdvErkQSdcrUMjP8AQW+tpdRmBjxR\n+jjHSmwKpFpcA2siXDasOZ6akgsIR2LrfghjjjkhjtrfvhS6IK4md580jy9urOJO\nmmSedE\/Ktq1g3upEoBlDREAnIk9fwaMK6NAQ3QsP0CR8achnoKjTFmK0CppCgQoz\nE6XaNEFyudUQdhHIaddfebK+t\/mu+Ddu0y0DL3q3w\/tAN7NdHdqeKT9CR2E395oD\nosoxeVfKFSpSHxBIz\/69WYjeoT6cNQkL\/fO4VMMjhghjfhgde323434iL5Devvxj\nnrzJ21GyBfcPxLp\/8YJHG757dRDheAoOXOzLeAf4Wu3a3y0NDiyjrpBN5vEGeObP\nJ6Z71XXBfME5\n=oJD2\n-----END PGP PUBLIC KEY BLOCK-----<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"revocation_of_a_key\">Revocation of a key<\/h3>\n\n\n\n<p>To revoke a key, first, make sure that the public key is accessible from the computer. Now, use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --import revcert.asc<\/code><\/pre>\n\n\n\n<p>Now, you can see the <code>revoked<\/code> word in the list of your secret and public keys:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ gpg --list-secret-keys\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\nsec   rsa3072 2023-02-17 &#91;SC] &#91;<span style=\"text-decoration: underline;\">revoked<\/span>: 2023-02-21]\n      03894010F347890A123DF87ABA7C45B7108F0083\nuid           &#91; <span style=\"text-decoration: underline;\">revoked<\/span>] Ajay Yadav &lt;xyx1@gmail.com&gt;\n\nsec   rsa3072 2023-02-17 &#91;SC]\n      91D335983408E555CFDC47D77F192C20064C28D5\nuid           &#91;ultimate] unblocked8888 &lt;xyx2@gmail.com&gt;\nssb   rsa3072 2023-02-17 &#91;E]\n\n$ gpg --list-public-keys\n\/home\/ajay\/.gnupg\/pubring.kbx\n-----------------------------\npub   rsa3072 2023-02-17 &#91;SC] &#91;<span style=\"text-decoration: underline;\">revoked<\/span>: 2023-02-21]\n      03894010F347890A123DF87ABA7C45B7108F0083\nuid           &#91; <span style=\"text-decoration: underline;\">revoked<\/span>] Ajay Yadav &lt;xyx1@gmail.com&gt;\n\npub   rsa3072 2023-02-17 &#91;SC]\n      91D335983408E555CFDC47D77F192C20064C28D5\nuid           &#91;ultimate] unblocked8888 &lt;xyx2@gmail.com&gt;\nsub   rsa3072 2023-02-17 &#91;E]<\/code><\/pre>\n\n\n\n<p>After revoking a public key, please send it to the keyserver and your communication partner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"changing_expiration_date_passphrase_etc_in_gpg\">Changing expiration date, passphrase, etc. in gpg<\/h2>\n\n\n\n<p>Use <code>--edit-key<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg --edit-key &lt;key-identifier&gt;<\/code><\/pre>\n\n\n\n<p>Type <code>help<\/code> to see the manual.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\ngpg&gt; help\n...\n&gt; passwd       # change the passphrase\n&gt; revkey       # revoke a key\n&gt; addkey       # add a subkey to this key\n&gt; expire       # change the key expiration time\n...\n...<\/code><\/pre>\n\n\n\n<p>You can change the expiration date of the key after it has expired using the <code>--edit-key<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>That was a basic introduction. To learn more, read the man page (man gpg). This gpg manual is a little bit old but explains cryptography etc. quite well. You can also use <strong>gpa, gpg-crypter, and gpg-tui <\/strong>if you fill uncomfortable with commands. If there is any mistake. Just tell me using the comment section. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is a comprehensive guide on GPG encryption and signature. Learn how public cryptography works and what are the GPG commands to encrypt and sign your files\/messages.<\/p>\n","protected":false},"author":2,"featured_media":2468,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[18],"class_list":["post-2433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools","tag-command-line-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to encrypt and Sign your files using GPG | SmartTech101<\/title>\n<meta name=\"description\" content=\"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to encrypt and Sign your files using GPG | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-12T13:11:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-12T13:11:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"How to encrypt and Sign your files using GPG\",\"datePublished\":\"2023-03-12T13:11:00+00:00\",\"dateModified\":\"2023-03-12T13:11:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\"},\"wordCount\":2479,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1\",\"keywords\":[\"Command Line Tools\"],\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\",\"url\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\",\"name\":\"How to encrypt and Sign your files using GPG | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2023-03-12T13:11:00+00:00\",\"dateModified\":\"2023-03-12T13:11:05+00:00\",\"description\":\"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"Comprehensive guide on GPG encryption and signature\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to encrypt and Sign your files using GPG\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to encrypt and Sign your files using GPG | SmartTech101","description":"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/","og_locale":"en_US","og_type":"article","og_title":"How to encrypt and Sign your files using GPG | SmartTech101","og_description":"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.","og_url":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/","og_site_name":"SmartTech101","article_published_time":"2023-03-12T13:11:00+00:00","article_modified_time":"2023-03-12T13:11:05+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"How to encrypt and Sign your files using GPG","datePublished":"2023-03-12T13:11:00+00:00","dateModified":"2023-03-12T13:11:05+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/"},"wordCount":2479,"commentCount":0,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1","keywords":["Command Line Tools"],"articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/","url":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/","name":"How to encrypt and Sign your files using GPG | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1","datePublished":"2023-03-12T13:11:00+00:00","dateModified":"2023-03-12T13:11:05+00:00","description":"In this article, I will talk about how gpg encryption\/decryption works. I will also talk about putting signatures on your files uings gpg.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"Comprehensive guide on GPG encryption and signature"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/how-to-encrypt-and-sign-your-files-using-gpg\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"How to encrypt and Sign your files using GPG"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/gpg-1.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2433"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=2433"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2433\/revisions"}],"predecessor-version":[{"id":2469,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2433\/revisions\/2469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/2468"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=2433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=2433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=2433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}