{"id":5534,"date":"2023-11-21T18:27:15","date_gmt":"2023-11-22T00:27:15","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=5534"},"modified":"2024-03-13T09:50:38","modified_gmt":"2024-03-13T14:50:38","slug":"export-gpg-private-key","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/export-gpg-private-key\/","title":{"rendered":"Import\/Export GPG Private Key"},"content":{"rendered":"\n<p>Note that if you need to copy both your Private and Public key, you&#8217;ll need to export both separately. <\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/5587513\/how-to-export-private-secret-asc-key-to-decrypt-gpg-files\">https:\/\/stackoverflow.com\/questions\/5587513\/how-to-export-private-secret-asc-key-to-decrypt-gpg-files<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">List Keys<\/h2>\n\n\n\n<p>You can list all the GPG keys with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --list-keys<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Export Key<\/h2>\n\n\n\n<p>Change &#8220;keyID&#8221; to your key idea from the above command.  The key ID is the long string of hexadecimal characters.  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --export-secret-keys \"keyID\" &gt; private_key.asc<\/pre>\n\n\n\n<p>This will export the keys to private_key.asc.  Rename as appropriate.<\/p>\n\n\n\n<p>To export the Public Key<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --export \"keyID\" &gt; public_key.asc<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Import Key<\/h2>\n\n\n\n<p>To use the key, you&#8217;ll need to import and trust the key.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --allow-secret-key-import --import private_key.asc<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --edit-key \"keyID\"<\/pre>\n\n\n\n<p>Then type<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">trust<\/pre>\n\n\n\n<p>Select level 5.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Import the Public Key<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gpg --import public_key.asc<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Decrypt Files<\/h2>\n\n\n\n<p>To decrypt a single file do<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> gpg --batch --passphrase='password' .\/file.gpg<\/pre>\n\n\n\n<p>If your GPG does not have a password, remove the whole `&#8211;passphrase=&#8217;password&#8217;` option<\/p>\n\n\n\n<p>To decrypt multiple files you can run<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">for file in * ; do gpg --batch --passphrase='password' \"$file\" ; done<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Note that if you need to copy both your Private and Public key, you&#8217;ll need to export both separately. https:\/\/stackoverflow.com\/questions\/5587513\/how-to-export-private-secret-asc-key-to-decrypt-gpg-files List Keys You can list all the GPG keys with the following command. gpg &#8211;list-keys Export Key Change &#8220;keyID&#8221; to &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/export-gpg-private-key\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[573],"tags":[575,175,80,307,1583,1586,1584,1585],"class_list":["post-5534","post","type-post","status-publish","format-standard","hentry","category-security","tag-encryption","tag-export","tag-gpg","tag-keys","tag-pgp","tag-pki","tag-private","tag-public-key"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=5534"}],"version-history":[{"count":3,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5534\/revisions"}],"predecessor-version":[{"id":5762,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/5534\/revisions\/5762"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=5534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=5534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=5534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}