<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1929&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / Safe GnuPG setup (with offlined master secret key)]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1929</link>
		<description><![CDATA[The most recent posts in Safe GnuPG setup (with offlined master secret key).]]></description>
		<lastBuildDate>Sun, 11 Mar 2018 23:18:37 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7934#p7934</link>
			<description><![CDATA[<p>From this page below:<br />--export-options export-reset-subkey-passwd<br /><a href="https://lists.gnupg.org/pipermail/gnupg-users/2018-March/060124.html" rel="nofollow">https://lists.gnupg.org/pipermail/gnupg … 60124.html</a><br />there might be corrections on my methods to be found, or more advice to read.</p><p>Regards!</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 23:18:37 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7934#p7934</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7928#p7928</link>
			<description><![CDATA[<p>I need to do some more checking... Well, the real checking is probably with hooks way deep into the code, which I am not apt to do now...<br />But this probably will work fine for me...</p><p>I might have to go without completely automatic signing subkey (with the password reset to empty).</p><p>Happy crypting, folks!</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 18:40:31 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7928#p7928</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7927#p7927</link>
			<description><![CDATA[<p>NOTE upon much later proofreading: I forgot the &quot;--homedir .&quot; below. But also with it (I repeated all with it, later), no luck.</p><div class="codebox"><pre><code>~/.gnupg-2$ gpg --edit-key 98ECA48587E811A1
Secret key is available.

sec  rsa4096/EA9884884FBAF0AE
     created: 2014-01-16  expires: 2019-05-19  usage: SC  
     trust: ultimate      validity: ultimate
ssb  rsa4096/C94689581D481BD5
     created: 2014-01-16  expires: never       usage: E   
ssb  rsa3072/98ECA48587E811A1
     created: 2018-03-10  expires: never       usage: S   
[ultimate] (1). Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
[ revoked] (2)  Miroslav Rovis (consecrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;

gpg&gt; passwd</code></pre></div><p>I <em>Cancel</em>&#039;d changing password for EA9884884FBAF0AE and C94689581D481BD5 and I am at:</p><div class="codebox"><pre><code>     ┌──────────────────────────────────────────────────────────────────────────────────┐
     │ Please enter the passphrase to unlock the OpenPGP secret key:                    │
     │ &quot;Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;&quot;  │
     │ 3072-bit RSA key, ID 98ECA48587E811A1,                                           │
     │ created 2018-03-10 (main key ID EA9884884FBAF0AE).                               │
     │                                                                                  │
     │                                                                                  │
     │ Passphrase: ____________________________________________________________________ │
     │                                                                                  │
     │            &lt;OK&gt;                                                &lt;Cancel&gt;          │
     └──────────────────────────────────────────────────────────────────────────────────┘</code></pre></div><p>where I entered the password that is still the same as for the primary key.</p><p>Upon which I get:</p><div class="codebox"><pre><code>                   ┌──────────────────────────────────────────────────────┐
                   │ Please enter the new passphrase                      │
                   │                                                      │
                   │ Passphrase: ________________________________________ │
                   │                                                      │
                   │       &lt;OK&gt;                              &lt;Cancel&gt;     │
                   └──────────────────────────────────────────────────────┘</code></pre></div><p>But there is no resetting the password. I leave empty (type nothing in the form after &quot;Passphrase:&quot;) and hit &quot;&lt;OK&gt;&quot; but all I get is the prompt is back again, and it would be back again forever. No changing of password there.</p><p>So, still stuck here...</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 18:38:03 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7927#p7927</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7926#p7926</link>
			<description><![CDATA[<p>This time I didn&#039;t delete, but moved it out of the working area:</p><div class="codebox"><pre><code>~$ mv -iv .gnupg-2 .gnupg-2-DEL1
renamed &#039;.gnupg-2&#039; -&gt; &#039;.gnupg-2-DEL1&#039;
~$</code></pre></div><p>The secring in that moved dir is same:</p><div class="codebox"><pre><code>~$ sha256sum secring.gpg .gnupg-2-DEL1/secring.gpg
28f35e3777ea2182c5ae925cc29628e9dad8ae7ee19ec0ba0d4ea8b753c02d1d  secring.gpg
28f35e3777ea2182c5ae925cc29628e9dad8ae7ee19ec0ba0d4ea8b753c02d1d  .gnupg-2-DEL1/secring.gpg
~$</code></pre></div><p>and can be deleted, so no ambiguity about the new secring.gpg arises.</p><div class="codebox"><pre><code>~$ rm secring.gpg
~$</code></pre></div><p>It&#039;s touchy here, every move must be right...</p><div class="codebox"><pre><code>~$ gpg --list-secret-keys EA9884884FBAF0AE
sec   rsa4096/EA9884884FBAF0AE 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE
uid                 [ultimate] Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
ssb   rsa4096/C94689581D481BD5 2014-01-16 [E]
ssb   rsa3072/98ECA48587E811A1 2018-03-10 [S]</code></pre></div><p>I&#039;ll now try, instead of just one subkey, export both.</p><div class="codebox"><pre><code>~$ gpg --output secring.gpg --export-secret-subkeys  98ECA48587E811A1! C94689581D481BD5!</code></pre></div><p>Hmmmh, why did I get:</p><div class="codebox"><pre><code>     ┌──────────────────────────────────────────────────────────────────────────────────┐
     │ Please enter the passphrase to export the OpenPGP secret subkey:                 │
     │ &quot;Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;&quot;  │
     │ 4096-bit RSA key, ID C94689581D481BD5,                                           │
     │ created 2014-01-16 (main key ID EA9884884FBAF0AE).                               │
     │                                                                                  │
     │                                                                                  │
     │ Passphrase: ***********_________________________________________________________ │
     │                                                                                  │
     │            &lt;OK&gt;                                                &lt;Cancel&gt;          │
     └──────────────────────────────────────────────────────────────────────────────────┘</code></pre></div><p>the password prompt for the first... Don&#039;t know, maybe that&#039;s OK...</p><p>The secring <em>is</em> bigger this time. Maybe it did take both subkeys as I wished it would.</p><div class="codebox"><pre><code>~$ ls -l secring.gpg .gnupg-2-DEL1/secring.gpg 
-rw------- 1 mr mr 5476 2018-03-10 20:12 .gnupg-2-DEL1/secring.gpg
-rw------- 1 mr mr 7887 2018-03-10 20:57 secring.gpg
~$</code></pre></div><p>Repasting the next step for clarity (it&#039;s the third time, but this is pretty hard stuff, newbies will be stumbling, and they do need it):</p><div class="codebox"><pre><code>~$ mkdir .gnupg-2
~$ chmod 700 .gnupg-2
~$ cp -iav .gnupg/pubring.* secring.gpg .gnupg-2
&#039;.gnupg/pubring.gpg&#039; -&gt; &#039;.gnupg-2/pubring.gpg&#039;
&#039;.gnupg/pubring.gpg~&#039; -&gt; &#039;.gnupg-2/pubring.gpg~&#039;
&#039;.gnupg/pubring.kbx&#039; -&gt; &#039;.gnupg-2/pubring.kbx&#039;
&#039;secring.gpg&#039; -&gt; &#039;.gnupg-2/secring.gpg&#039;
~$ cd .gnupg-2
~/.gnupg-2$</code></pre></div><p>Again, but the slight difference is important (find it yourself, gentle reader):</p><div class="codebox"><pre><code>~$ ls -lRa
.:
total 11852
drwx------  2 mr mr    4096 2018-03-10 21:01 .
drwxr-xr-x 51 mr mr   20480 2018-03-10 20:59 ..
-rw-------  1 mr mr 6038487 2018-03-10 20:07 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr    7887 2018-03-10 20:57 secring.gpg
~$</code></pre></div><p>Now:</p><div class="codebox"><pre><code>~/.gnupg-2$ gpg --homedir . --list-secret-keys
gpg: starting migration from earlier GnuPG versions
gpg: porting secret keys from &#039;/home/mr/.gnupg-2/secring.gpg&#039; to gpg-agent
gpg: To migrate &#039;secring.gpg&#039;, with each smartcard, run: gpg --card-status
gpg: key EA9884884FBAF0AE: secret key imported
gpg: migration succeeded
gpg: /home/mr/.gnupg-2/trustdb.gpg: trustdb created
/home/mr/.gnupg-2/pubring.gpg
-----------------------------
sec#  rsa4096 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE
uid           [ unknown] Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
ssb   rsa4096 2014-01-16 [E]
ssb   rsa3072 2018-03-10 [S]

~/.gnupg-2$</code></pre></div><p>got me both the subkeys, while the <em><strong>sec#</strong></em> adamantly claims that the primary key is not at risk.</p><div class="codebox"><pre><code>~/.gnupg-2$ ls -lRa
.:
total 11860
drwx------  3 mr mr    4096 2018-03-10 21:05 .
drwxr-xr-x 51 mr mr   20480 2018-03-10 20:59 ..
-rw-r--r--  1 mr mr       0 2018-03-10 21:05 .gpg-v21-migrated
drwx------  2 mr mr    4096 2018-03-10 21:05 private-keys-v1.d
-rw-------  1 mr mr 6038487 2018-03-10 20:07 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr    7887 2018-03-10 20:57 secring.gpg
srwx------  1 mr mr       0 2018-03-10 21:05 S.gpg-agent
srwx------  1 mr mr       0 2018-03-10 21:05 S.gpg-agent.browser
srwx------  1 mr mr       0 2018-03-10 21:05 S.gpg-agent.extra
srwx------  1 mr mr       0 2018-03-10 21:05 S.gpg-agent.ssh
-rw-------  1 mr mr    1200 2018-03-10 21:05 trustdb.gpg

./private-keys-v1.d:
total 16
drwx------ 2 mr mr 4096 2018-03-10 21:05 .
drwx------ 3 mr mr 4096 2018-03-10 21:05 ..
-rw------- 1 mr mr 2578 2018-03-10 21:05 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85.key
-rw------- 1 mr mr 2001 2018-03-10 21:05 6D97E1E61FD4350A1E6E246819CCF06BDC5DEF94.key
~/.gnupg-2$</code></pre></div><p>Phew!</p><p>The password now, in the next post.</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 18:36:48 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7926#p7926</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7925#p7925</link>
			<description><![CDATA[<p>Alright, maybe I&#039;m making it.</p><p>This is the listing o my full key, never online, never-ever:</p><div class="codebox"><pre><code>$ ls -lRa .gnupg
.gnupg:
total 11920
drwx------  3 mr mr    4096 2018-03-10 16:24 .
drwxr-xr-x 49 mr mr   20480 2018-03-10 19:35 ..
-rw-------  1 mr mr    8098 2018-03-10 16:24 gpg.conf
-rw-------  1 mr mr       0 2017-01-25 09:21 .gpg-v21-migrated
drwx------  2 mr mr    4096 2017-01-25 09:21 private-keys-v1.d
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr     600 2018-02-16 13:30 random_seed
-rw-------  1 mr mr   11535 2014-05-20 20:39 secring.gpg
-rw-r--r--  1 mr mr   49152 2017-07-09 04:44 tofu.db
-rw-------  1 mr mr    1720 2017-11-18 14:28 trustdb.gpg

.gnupg/private-keys-v1.d:
total 32
drwx------ 2 mr mr 4096 2017-01-25 09:21 .
drwx------ 3 mr mr 4096 2018-03-10 16:24 ..
-rw------- 1 mr mr 2071 2017-01-25 09:38 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85.key
-rw------- 1 mr mr 2055 2017-01-25 09:34 69DCB3F7DFF03B916BFADC92F522F46A64565D92.key
-rw------- 1 mr mr 2571 2017-01-25 09:21 959336EEAAFDB6BFDDFE31DA64D5D9130BE96C85.key
-rw------- 1 mr mr 1118 2017-01-25 09:21 B3B690001E37C098B1CA3D8F30F1DDD1A5EA6690.key
-rw------- 1 mr mr 2571 2017-01-25 09:21 B555D13FEBE540A4BB84AA2ED0B2E7C69829DE29.key
-rw------- 1 mr mr  540 2017-10-17 15:17 EF856BB2FD4F96DCCF199A7D1B8641B5A1F6B034.key
$</code></pre></div><p>The link with the <strong>--output</strong> suggestion (and the <em>!</em> at end of subkeyID) was right, I might have just made it a better way than before, and I&#039;m recreating the procedure and pasting the story as I go. BTW, previously I was doing it by copying over from the <strong>private-keys-v1.d</strong> directory the right files, and that&#039;s probably not right.</p><div class="codebox"><pre class="vscroll"><code>~$ gpg --edit-key EA9884884FBAF0AE
Secret key is available.

sec  rsa4096/EA9884884FBAF0AE
     created: 2014-01-16  expires: 2019-05-19  usage: SC  
     trust: ultimate      validity: ultimate
ssb  rsa4096/C94689581D481BD5
     created: 2014-01-16  expires: never       usage: E   
[ultimate] (1). Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
[ revoked] (2)  Miroslav Rovis (consecrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;

gpg&gt; addkey
Please select what kind of key you want:
   (3) DSA (sign only)
   (4) RSA (sign only)
   (5) Elgamal (encrypt only)
   (6) RSA (encrypt only)
Your selection? 4
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 
Requested keysize is 3072 bits
Please specify how long the key should be valid.
         0 = key does not expire
      &lt;n&gt;  = key expires in n days
      &lt;n&gt;w = key expires in n weeks
      &lt;n&gt;m = key expires in n months
      &lt;n&gt;y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) y
Really create? (y/N) y</code></pre></div><p>And I got here the ncurses (I could never go for GUI stuff to input password, yuk!):</p><div class="codebox"><pre><code>     ┌──────────────────────────────────────────────────────────────────────────────────┐
     │ Please enter the passphrase to unlock the OpenPGP secret key:                    │
     │ &quot;Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;&quot;  │
     │ 4096-bit RSA key, ID EA9884884FBAF0AE,                                           │
     │ created 2014-01-16.                                                              │
     │                                                                                  │
     │                                                                                  │
     │ Passphrase: ***********_________________________________________________________ │
     │                                                                                  │
     │            &lt;OK&gt;                                                &lt;Cancel&gt;          │
     └──────────────────────────────────────────────────────────────────────────────────┘</code></pre></div><p>And once it returned the prompt:</p><div class="codebox"><pre><code>We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

sec  rsa4096/EA9884884FBAF0AE
     created: 2014-01-16  expires: 2019-05-19  usage: SC  
     trust: ultimate      validity: ultimate
ssb  rsa4096/C94689581D481BD5
     created: 2014-01-16  expires: never       usage: E   
ssb  rsa3072/98ECA48587E811A1
     created: 2018-03-10  expires: never       usage: S   
[ultimate] (1). Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
[ revoked] (2)  Miroslav Rovis (consecrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;

gpg&gt;</code></pre></div><p>where the subkey <strong>98ECA48587E811A1</strong> has just been created.</p><p>Now I&#039;m just not in the clear about password. It seems (to me) the FAQ is wrong about the redirection (the <strong>&gt;</strong>) which it uses, as well as it fails to advise the user to add the <strong>!</strong> immediately following the chosen subkey ID. But I don&#039;t know about it&#039;s claim about the password. I&#039;ll still try to use the password somehow on the new key...</p><p>Let&#039;s see.</p><div class="codebox"><pre><code>gpg&gt; password</code></pre></div><p>It gave me exactly the same terminal look as 30 lines above here. And I input the very same password. The FAQ doesn&#039;t say <em>change</em> the password, but just <em>use</em> it. So on this screen:</p><div class="codebox"><pre><code>                   ┌──────────────────────────────────────────────────────┐
                   │ Please enter the new passphrase                      │
                   │                                                      │
                   │ Passphrase: ________________________________________ │
                   │                                                      │
                   │       &lt;OK&gt;                              &lt;Cancel&gt;     │
                   └──────────────────────────────────────────────────────┘</code></pre></div><p>I simply chose and hit Enter on <em>Cancel</em>.</p><p>Then I am presented with:</p><div class="codebox"><pre><code>    ┌──────────────────────────────────────────────────────────────────────────────────┐
     │ Please enter the passphrase to unlock the OpenPGP secret key:                    │
     │ &quot;Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;&quot;  │
     │ 4096-bit RSA key, ID C94689581D481BD5,                                           │
     │ created 2014-01-16 (main key ID EA9884884FBAF0AE).                               │
     │                                                                                  │
     │                                                                                  │
     │ Passphrase: ____________________________________________________________________ │
     │                                                                                  │
     │            &lt;OK&gt;                                                &lt;Cancel&gt;          │
     └──────────────────────────────────────────────────────────────────────────────────┘</code></pre></div><p>which is the encryption subkey. Again, just entered (it&#039;s still same password) the password...</p><p>NOTE: interruption here because of the timeout, but I&#039;ll repeat the procedure as above.</p><p>Continuing where I left in the procedure before timeout (which I repeated meticulously.</p><p>And of course I canceled changing the password on that one too in the same fashion.</p><p>And I am presented with the key that I would so much like to have empty password on it.</p><div class="codebox"><pre><code>     ┌──────────────────────────────────────────────────────────────────────────────────┐
     │ Please enter the passphrase to unlock the OpenPGP secret key:                    │
     │ &quot;Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;&quot;  │
     │ 3072-bit RSA key, ID 98ECA48587E811A1,                                           │
     │ created 2018-03-10 (main key ID EA9884884FBAF0AE).                               │
     │                                                                                  │
     │                                                                                  │
     │ Passphrase: ____________________________________________________________________ │
     │                                                                                  │
     │            &lt;OK&gt;                                                &lt;Cancel&gt;          │
     └──────────────────────────────────────────────────────────────────────────────────┘</code></pre></div><p>and in this attempt (if it only be the last one... but who knows if it&#039;ll work without changing that password; I mean, with changing the password later in the new, testing should I call it, directory?), and in this attempt I <em>Cancel</em>&#039;ed it too.</p><p>Now we only go:</p><div class="codebox"><pre><code>gpg&gt; quit
Save changes? (y/N) y
~$</code></pre></div><p>And now I plan to issue:</p><div class="codebox"><pre><code>$ gpg --output secring.gpg --export-secret-subkeys  98ECA48587E811A1!</code></pre></div><p>(pls. notice the exclamation mark immediately following the 16-hex char string of the new subkey ID)</p><p>Shall we?</p><div class="codebox"><pre><code> it was silence, no output, suspense...

 suspense...

 suspense...</code></pre></div><p>There were no errors, the key must have been produced...</p><div class="codebox"><pre><code>~$ ls -l secring.gpg
-rw------- 1 mr mr 5476 2018-03-10 20:12 secring.gpg
~$</code></pre></div><p>So... Let&#039;s prepare the testing, should I call it, directory...</p><div class="codebox"><pre><code>~$ mkdir .gnupg-TEST
~$ chmod 700 .gnupg-TEST/
~$ ls -lRa .gnupg-TEST/
.gnupg-TEST/:
total 24
drwx------  2 mr mr  4096 2018-03-10 20:15 .
drwxr-xr-x 50 mr mr 20480 2018-03-10 20:15 ..
~$</code></pre></div><p>Now, as the FAQ says, let&#039;s copy the public key and this secring.gpg into it.</p><div class="codebox"><pre><code>~$ cp -iav .gnupg/pubring.* secring.gpg .gnupg-TEST/
&#039;.gnupg/pubring.gpg&#039; -&gt; &#039;.gnupg-TEST/pubring.gpg&#039;
&#039;.gnupg/pubring.gpg~&#039; -&gt; &#039;.gnupg-TEST/pubring.gpg~&#039;
&#039;.gnupg/pubring.kbx&#039; -&gt; &#039;.gnupg-TEST/pubring.kbx&#039;
&#039;secring.gpg&#039; -&gt; &#039;.gnupg-TEST/secring.gpg&#039;
~$ ls -lRa .gnupg-TEST/
.gnupg-TEST/:
total 11852
drwx------  2 mr mr    4096 2018-03-10 20:17 .
drwxr-xr-x 50 mr mr   20480 2018-03-10 20:15 ..
-rw-------  1 mr mr 6038487 2018-03-10 20:07 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr    5476 2018-03-10 20:12 secring.gpg
~$</code></pre></div><p>Entering that directory. No typoes allowed during all this time, this is pretty stressful with concentration...</p><div class="codebox"><pre><code>~$ cd .gnupg-TEST
~/.gnupg-TEST$</code></pre></div><p>Now if it all (or be it just most of it... I fear I might not get the password reset easily yet, but who knows...) goes well, I should get the notice about <em>starting migration</em> and more (I&#039;ve had it in my Air-Gapped machine before going over to prepare this into the online clone of that Air-Gapped).</p><p>And merely bey listing the (secret) keys.</p><p>NOTE: Very important to not forget the <em>--homedir . </em> option here.</p><div class="codebox"><pre><code>$ gpg --homedir . --list-secret-keys
gpg: starting migration from earlier GnuPG versions
gpg: DBG: locking for &#039;/home/mr/.gnupg-TEST/.gpg-v21-migrated.lock&#039; done via O_EXCL
gpg: DBG: locking for &#039;/home/mr/.gnupg-TEST/gnupg_spawn_agent_sentinel.lock&#039; done via O_EXCL
gpg: porting secret keys from &#039;/home/mr/.gnupg-TEST/secring.gpg&#039; to gpg-agent
gpg: DBG: locking for &#039;/home/mr/.gnupg-TEST/pubring.gpg.lock&#039; done via O_EXCL
gpg: release_dotlock: error removing lockfile &#039;/home/mr/.gnupg-TEST/pubring.gpg.lock&#039;
gpg: can&#039;t unlock &#039;/home/mr/.gnupg-TEST/pubring.gpg&#039;
gpg: To migrate &#039;secring.gpg&#039;, with each smartcard, run: gpg --card-status
gpg: key EA9884884FBAF0AE: secret key imported
gpg: migration succeeded
gpg: release_dotlock: error removing lockfile &#039;/home/mr/.gnupg-TEST/.gpg-v21-migrated.lock&#039;
gpg: failed to create temporary file &#039;/home/mr/.gnupg-TEST/.#lk0x0000007754552660.gdOv.1580&#039;: File exists
gpg: Fatal: can&#039;t create lock for &#039;/home/mr/.gnupg-TEST/trustdb.gpg&#039;</code></pre></div><p>Ah, I forgot to setup grsec rules for it... But this should be no worry, I&#039;ll just call the dir differently, fora name that will fit the rules...</p><p>However, I&#039;ll repeat the procedure, sorry for the inconvenience, since this is not neat to see...</p><p>See:</p><div class="codebox"><pre class="vscroll"><code>~/.gnupg-TEST$ ls -lRa
.:
total 11880
drwx------  3 mr mr    4096 2018-03-10 20:23 .
drwxr-xr-x 50 mr mr   20480 2018-03-10 20:15 ..
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 gnupg_spawn_agent_sentinel.lock
-rw-r--r--  1 mr mr       0 2018-03-10 20:23 .gpg-v21-migrated
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 .gpg-v21-migrated.lock
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 .#lk0x0000007754552660.gdOv.1580
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 .#lk0x0000007754554800.gdOv.1580
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 .#lk0x0000007754554890.gdOv.1580
drwx------  2 mr mr    4096 2018-03-10 20:23 private-keys-v1.d
-rw-------  1 mr mr 6038487 2018-03-10 20:07 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr      16 2018-03-10 20:23 pubring.gpg.lock
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr    5476 2018-03-10 20:12 secring.gpg
srwx------  1 mr mr       0 2018-03-10 20:23 S.gpg-agent
srwx------  1 mr mr       0 2018-03-10 20:23 S.gpg-agent.browser
srwx------  1 mr mr       0 2018-03-10 20:23 S.gpg-agent.extra
srwx------  1 mr mr       0 2018-03-10 20:23 S.gpg-agent.ssh

./private-keys-v1.d:
total 12
drwx------ 2 mr mr 4096 2018-03-10 20:23 .
drwx------ 3 mr mr 4096 2018-03-10 20:23 ..
-rw------- 1 mr mr 2001 2018-03-10 20:23 6D97E1E61FD4350A1E6E246819CCF06BDC5DEF94.key
~/.gnupg-TEST$</code></pre></div><p>That&#039;s not completely right.</p><div class="codebox"><pre><code>~$ rm -rf .gnupg-TEST/
~$</code></pre></div><p>More quickly this time:</p><div class="codebox"><pre><code>~$ mkdir .gnupg-2
~$ chmod 700 .gnupg-2
~$ cp -iav .gnupg/pubring.* secring.gpg .gnupg-2
&#039;.gnupg/pubring.gpg&#039; -&gt; &#039;.gnupg-2/pubring.gpg&#039;
&#039;.gnupg/pubring.gpg~&#039; -&gt; &#039;.gnupg-2/pubring.gpg~&#039;
&#039;.gnupg/pubring.kbx&#039; -&gt; &#039;.gnupg-2/pubring.kbx&#039;
&#039;secring.gpg&#039; -&gt; &#039;.gnupg-2/secring.gpg&#039;
~$ cd .gnupg-2
~/.gnupg-2$</code></pre></div><p>Still not right:</p><div class="codebox"><pre><code>~/.gnupg-2$ gpg --homedir . --list-secret-keys
gpg: starting migration from earlier GnuPG versions
gpg: DBG: locking for &#039;/home/mr/.gnupg-2/.gpg-v21-migrated.lock&#039; done via O_EXCL
gpg: DBG: locking for &#039;/home/mr/.gnupg-2/gnupg_spawn_agent_sentinel.lock&#039; done via O_EXCL
gpg: porting secret keys from &#039;/home/mr/.gnupg-2/secring.gpg&#039; to gpg-agent
gpg: DBG: locking for &#039;/home/mr/.gnupg-2/pubring.gpg.lock&#039; done via O_EXCL
gpg: release_dotlock: error removing lockfile &#039;/home/mr/.gnupg-2/pubring.gpg.lock&#039;
gpg: can&#039;t unlock &#039;/home/mr/.gnupg-2/pubring.gpg&#039;
gpg: To migrate &#039;secring.gpg&#039;, with each smartcard, run: gpg --card-status
gpg: key EA9884884FBAF0AE: secret key imported
gpg: migration succeeded
gpg: release_dotlock: error removing lockfile &#039;/home/mr/.gnupg-2/.gpg-v21-migrated.lock&#039;
gpg: failed to create temporary file &#039;/home/mr/.gnupg-2/.#lk0x000000362630a220.gdOv.1600&#039;: File exists
gpg: Fatal: can&#039;t create lock for &#039;/home/mr/.gnupg-2/trustdb.gpg&#039;
~/.gnupg-2$</code></pre></div><p>(the listing being similar to the immediately previous attempt just above)</p><p>and in the logs:</p><div class="codebox"><pre><code>Mar 10 20:29:09 gdOv kernel: [348585.016922] grsec: (mr:U:/usr/bin/gpg) exec of /usr/bin/gpg (gpg --homedir . --list-secret-keys ) by /usr/bin/gpg[bash:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.032547] grsec: (mr:U:/usr/bin/gpg) denied link of /home/mr/.gnupg-2/.#lk0x000000362630a220.gdOv.1600 to /home/mr/.gnupg-2/.#lk0x000000362630a220.gdOv.1600x by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.032643] grsec: (mr:U:/usr/bin/gpg) denied unlink of /home/mr/.gnupg-2/.#lk0x000000362630a220.gdOv.1600 by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.034393] grsec: (mr:U:/usr/bin/gpg) denied link of /home/mr/.gnupg-2/.#lk0x000000362630c3c0.gdOv.1600 to /home/mr/.gnupg-2/.#lk0x000000362630c3c0.gdOv.1600x by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.034482] grsec: (mr:U:/usr/bin/gpg) denied unlink of /home/mr/.gnupg-2/.#lk0x000000362630c3c0.gdOv.1600 by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.037410] grsec: (mr:U:/usr/bin/gpg) chdir to / by /usr/bin/gpg[gpg:1601] uid/euid:1000/1000 gid/egid:1000/1000, parent /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.040523] grsec: (mr:U:/usr/bin/gpg-agent) exec of /usr/bin/gpg-agent (gpg-agent --homedir /home/mr/.gnupg-2 --use-standard-socket --daemon ) by /usr/bin/gpg-agent[gpg:1602] uid/euid:1000/1000 gid/egid:1000/1000, parent /sbin/init[init:1] uid/euid:0/0 gid/egid:0/0
Mar 10 20:29:09 gdOv kernel: [348585.053064] grsec: (mr:U:/usr/bin/gpg-agent) chdir to / by /usr/bin/gpg-agent[gpg-agent:1603] uid/euid:1000/1000 gid/egid:1000/1000, parent /[gpg-agent:1602] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.057464] grsec: (mr:U:/usr/bin/gpg) denied unlink of /home/mr/.gnupg-2/gnupg_spawn_agent_sentinel.lock by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.067366] grsec: (mr:U:/usr/bin/gpg) denied link of /home/mr/.gnupg-2/.#lk0x000000362630c450.gdOv.1600 to /home/mr/.gnupg-2/.#lk0x000000362630c450.gdOv.1600x by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.067462] grsec: (mr:U:/usr/bin/gpg) denied unlink of /home/mr/.gnupg-2/.#lk0x000000362630c450.gdOv.1600 by /usr/bin/gpg[gpg:1600] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:29:09 gdOv kernel: [348585.071960] grsec: more alerts, logging disabled for 10 seconds</code></pre></div><p>It was these lines that were missing, and this is short and incomplete explanation of the RBAC grsec rules details here:</p><div class="codebox"><pre><code># diff grsec_180310_164427_5 /etc/grsec/policy 
7502d7501
&lt;       /home/mr/.gnupg-2               rwcdl
8170,8172d8168
&lt;       /home
&lt;       /home/mr
&lt;       /home/mr/.gnupg*                rwcdl</code></pre></div><p>Now rm -rf this one dir:</p><div class="codebox"><pre><code>~$ rm -rf .gnupg-2
~$</code></pre></div><p>And recreating it as I showed above (repasting for clarity:</p><div class="codebox"><pre><code>~$ mkdir .gnupg-2
~$ chmod 700 .gnupg-2
~$ cp -iav .gnupg/pubring.* secring.gpg .gnupg-2
&#039;.gnupg/pubring.gpg&#039; -&gt; &#039;.gnupg-2/pubring.gpg&#039;
&#039;.gnupg/pubring.gpg~&#039; -&gt; &#039;.gnupg-2/pubring.gpg~&#039;
&#039;.gnupg/pubring.kbx&#039; -&gt; &#039;.gnupg-2/pubring.kbx&#039;
&#039;secring.gpg&#039; -&gt; &#039;.gnupg-2/secring.gpg&#039;
~$ cd .gnupg-2
~/.gnupg-2$</code></pre></div><p>The logs, first:</p><div class="codebox"><pre><code>Mar 10 20:40:49 gdOv kernel: [349284.930930] grsec: (mr:U:/usr/bin/gpg) exec of /usr/bin/gpg (gpg --homedir . --list-secret-keys ) by /usr/bin/gpg[bash:1704] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:29862] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:40:49 gdOv kernel: [349284.948780] grsec: (mr:U:/usr/bin/gpg) chdir to / by /usr/bin/gpg[gpg:1705] uid/euid:1000/1000 gid/egid:1000/1000, parent /usr/bin/gpg[gpg:1704] uid/euid:1000/1000 gid/egid:1000/1000
Mar 10 20:40:49 gdOv kernel: [349284.950945] grsec: (mr:U:/usr/bin/gpg-agent) exec of /usr/bin/gpg-agent (gpg-agent --homedir /home/mr/.gnupg-2 --use-standard-socket --daemon ) by /usr/bin/gpg-agent[gpg:1706] uid/euid:1000/1000 gid/egid:1000/1000, parent /sbin/init[init:1] uid/euid:0/0 gid/egid:0/0
Mar 10 20:40:49 gdOv kernel: [349284.961521] grsec: (mr:U:/usr/bin/gpg-agent) chdir to / by /usr/bin/gpg-agent[gpg-agent:1707] uid/euid:1000/1000 gid/egid:1000/1000, parent /[gpg-agent:1706] uid/euid:1000/1000 gid/egid:1000/1000</code></pre></div><p>That&#039;s call neat logs by grsecurity.</p><p>Of course the standard output is equally beautiful:</p><div class="codebox"><pre><code>~/.gnupg-2$ gpg --homedir . --list-secret-keys
gpg: starting migration from earlier GnuPG versions
gpg: porting secret keys from &#039;/home/mr/.gnupg-2/secring.gpg&#039; to gpg-agent
gpg: To migrate &#039;secring.gpg&#039;, with each smartcard, run: gpg --card-status
gpg: key EA9884884FBAF0AE: secret key imported
gpg: migration succeeded
gpg: /home/mr/.gnupg-2/trustdb.gpg: trustdb created
/home/mr/.gnupg-2/pubring.gpg
-----------------------------
sec#  rsa4096 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE
uid           [ unknown] Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
ssb#  rsa4096 2014-01-16 [E]
ssb   rsa3072 2018-03-10 [S]

~/.gnupg-2$</code></pre></div><p>I pasted it complete with even the empty line it close its talk this time.</p><p>And the .gnupg-2/ directory now looks like this:</p><div class="codebox"><pre><code>~/.gnupg-2$ ls -lRa
.:
total 11860
drwx------  3 mr mr    4096 2018-03-10 20:40 .
drwxr-xr-x 50 mr mr   20480 2018-03-10 20:39 ..
-rw-r--r--  1 mr mr       0 2018-03-10 20:40 .gpg-v21-migrated
drwx------  2 mr mr    4096 2018-03-10 20:40 private-keys-v1.d
-rw-------  1 mr mr 6038487 2018-03-10 20:07 pubring.gpg
-rw-------  1 mr mr 6037010 2017-11-18 14:28 pubring.gpg~
-rw-r--r--  1 mr mr   22093 2012-11-12 03:10 pubring.kbx
-rw-------  1 mr mr    5476 2018-03-10 20:12 secring.gpg
srwx------  1 mr mr       0 2018-03-10 20:40 S.gpg-agent
srwx------  1 mr mr       0 2018-03-10 20:40 S.gpg-agent.browser
srwx------  1 mr mr       0 2018-03-10 20:40 S.gpg-agent.extra
srwx------  1 mr mr       0 2018-03-10 20:40 S.gpg-agent.ssh
-rw-------  1 mr mr    1200 2018-03-10 20:40 trustdb.gpg

./private-keys-v1.d:
total 12
drwx------ 2 mr mr 4096 2018-03-10 20:40 .
drwx------ 3 mr mr 4096 2018-03-10 20:40 ..
-rw------- 1 mr mr 2001 2018-03-10 20:40 6D97E1E61FD4350A1E6E246819CCF06BDC5DEF94.key
~/.gnupg-2$</code></pre></div><p>Hmmhh... Not sure if this is all that I expected, or even if this is really it, even partly...</p><p>Now it&#039;s not, the encrypting sub is also offlined...<br />See:</p><div class="codebox"><pre><code>ssb#  rsa4096 2014-01-16 [E]</code></pre></div><p>Partly OK it might be though... Some progress there, I&#039;d still say that I made...</p><p>What do I try first, the password reset, or getting the encryption subkey into there?</p><p>I&#039;ll try first another try to get the encryption subkey in.</p><p>In the next post.</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 18:35:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7925#p7925</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7924#p7924</link>
			<description><![CDATA[<p>Just solved this issue probably well. See:</p><p><a href="https://github.com/miroR/uncenz/releases/tag/v0.31" rel="nofollow">https://github.com/miroR/uncenz/releases/tag/v0.31</a></p><p>where you can find:<br />[ this same title as in top of page ]<br /><a href="https://dev1galaxy.org/viewtopic.php?id=1929" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=1929</a></p><p>and some code.</p><p>And v0.31 is verified.</p><p>But I have a backlog of some 3 or so posts (that I had prepared previously) to share.</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sun, 11 Mar 2018 18:31:23 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7924#p7924</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7915#p7915</link>
			<description><![CDATA[<p>I opened a topic at:<br />&quot;[ quote ] was opened within [ s ]&quot; FluxBB bug?<br /><a href="https://dev1galaxy.org/viewtopic.php?id=1930" rel="nofollow">https://dev1galaxy.org/viewtopic.php?id=1930</a></p><p>(and I&#039;ll dedicate it as much time as I can/is needed, whichever possible/necessary)</p><p>But I went through this &quot;Safe GnuPG setup&quot; procedure, and there&#039;s more...<br />First, can&#039;t do it in such way that on signing subkey I may remove passwd.<br />Second, here the references from GnuPG users:</p><p>--export-options export-reset-subkey-passwd<br /><a href="https://lists.gnupg.org/pipermail/gnupg-users/2018-January/059887.html" rel="nofollow">https://lists.gnupg.org/pipermail/gnupg … 59887.html</a></p><p>where it links to a bug, which this referrer said is:<br />&gt; Unfortunately this is still an open bug:</p><p>export-reset-subkey-passwd no longer works in GnuPG 2.1.0<br /><a href="https://dev.gnupg.org/T1753" rel="nofollow">https://dev.gnupg.org/T1753</a></p><p>And the discussion I found so far is at:</p><p>--export-options export-reset-subkey-passwd in gpg 2.1.x<br /><a href="https://lists.gnupg.org/pipermail/gnupg-devel/2014-October/thread.html#28919" rel="nofollow">https://lists.gnupg.org/pipermail/gnupg … html#28919</a></p><p>Also, another reference, maybe it&#039;s not exactly the right way to use redirection as in the FAQ item that I linked<br />(</p><div class="codebox"><pre><code>gpg --export-secret-subkeys --no-comment newsubkeyID &gt; secring.auto</code></pre></div><p>)<br />but rather to use the --output or -o to save the subkeys.</p><p>And, another thing, only one subkey at a time (I was trying to export two subkeys, the one for [E] and the other for [ S ]).<br />As per:<br />export encryption (subkey) only?<br /><a href="https://lists.gnupg.org/pipermail/gnupg-users/2017-January/057400.html" rel="nofollow">https://lists.gnupg.org/pipermail/gnupg … 57400.html</a></p><p>BTW, let&#039;s see if I can get this post to be accepted with the [ S ].</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sat, 10 Mar 2018 18:15:47 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7915#p7915</guid>
		</item>
		<item>
			<title><![CDATA[Re: Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7908#p7908</link>
			<description><![CDATA[<p>Due to the FluxBB bug that I described in bottom (for which I had to revise the text a few too many times), I mixed the parts of the text a little... Sorry!... Patience...</p>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sat, 10 Mar 2018 12:57:31 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7908#p7908</guid>
		</item>
		<item>
			<title><![CDATA[Safe GnuPG setup (with offlined master secret key)]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=7907#p7907</link>
			<description><![CDATA[<p>EDIT (much later): One very important detail I forgot to put forth:</p><div class="codebox"><pre><code>$ gpg --version
gpg (GnuPG) 2.2.5
libgcrypt 1.8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;https://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/mr/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
$</code></pre></div><p>---</p><p>I finally learned the knowhow of a good GnuPG setup, these days. And there&#039;s not many tutorials around with anything close to complete guidance, so I thought I would share this with other Devuan/Debian readers. It&#039;s not Devuan/Debian specific. It is attainable in any GNU/Linux, and I believe BSD and other Unices, distro.</p><p>Keeping the entire <strong>.gnupg/</strong> online, with complete primary (master) key would be calling for being rooted and pawned. So for a few years now, I have been using a setup that is surely safe, but it&#039;s always plug the USB-stick in, and play again and again with cryptsetup and mount to be able to sign and/or encrypt emails/other stuff, and don&#039;t in the world forget to unmount and cryptsetup close the device/partition on the USB-stick... It&#039;s a lot of overhead [1].</p><p>Here, this is the GnuPG setup which you can be reasonably sure is safe to use.</p><div class="codebox"><pre><code>~$ gpg --list-keys
/home/mr/.gnupg/pubring.gpg
---------------------------
pub   rsa4096 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE
uid           [ unknown] Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
sub   rsa4096 2014-01-16 [E]
sub   rsa3072 2018-03-08 [ S ]

~$ gpg --list-secret-keys
/home/mr/.gnupg/pubring.gpg
---------------------------
sec#  rsa4096 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE
uid           [ unknown] Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
ssb   rsa4096 2014-01-16 [E]
ssb   rsa3072 2018-03-08 [ S ]

~$ </code></pre></div><p>It&#039;s incomplete, in my practicing I had removed all other keys but this one (and I have a hundred something public keys from people from various areas of FOSS), and it&#039;s temporary, but this should work safely being online all the time that I am online with my machine, for anything I may need GnuPG for, and also, pretty bare as it is, it&#039;s easier to explain it to less advanced readers.</p><p>What we are talking here is the:</p><div class="codebox"><pre><code>sec#  rsa4096 2014-01-16 [SC] [expires: 2019-05-19]
      FCF13245ED247DCE443855B7EA9884884FBAF0AE</code></pre></div><p>secret key of the primary key being disabled, unavailable. The <em><strong>#</strong></em> in <em><strong>sec#</strong></em> says so. And even if the two subkeys, the one for encryption (marked with the <em><strong> [E] </strong></em>), and the one for signing (marked with the <em><strong> [ S ] </strong></em>), are disposable by me at any time, should I feel I need to revoke them and replace them with other subkeys, I don&#039;t depend on them!</p><p>There surely are drawbacks of revoking subkeys, but that&#039;s nowhere near a catastrophy by any means, as a compromise of the primary key would be.</p><p>If my primary secret key were compromized, good bye friends, no one would be able to help me, I&#039;d be &quot;doomed&quot;. But the primary secret key is unusable, disabled in this setup! No one can get hold of it!</p><p>The condition, the state of this GnuPG setup, is what is described in the:</p><p>The GNU Privacy Guard Manual (version 2.2.5, February 2018)<br /><a href="https://gnupg.org/documentation/manuals/gnupg/" rel="nofollow">https://gnupg.org/documentation/manuals/gnupg/</a><br /><a href="https://gnupg.org/documentation/manuals/gnupg.pdf" rel="nofollow">https://gnupg.org/documentation/manuals/gnupg.pdf</a> [2]</p><div class="quotebox"><blockquote><div><p>--list-secret-keys<br />-K&#160; &#160; &#160; &#160; List the specified secret keys. If no keys are specified, then all known secret<br />&#160; &#160; &#160; &#160; &#160; keys are listed.</p><p>&#160; &#160; &#160; &#160; &#160; A # after the initial tags sec or ssb means that the secret key or<br />&#160; &#160; &#160; &#160; &#160; subkey is currently not usable.</p><p>&#160; &#160; &#160; &#160; &#160; We also say that this key has been taken offline<br />&#160; &#160; &#160; &#160; &#160; (for example, a primary key can be taken offline by exporting the key using the<br />&#160; &#160; &#160; &#160; &#160; command ‘--export-secret-subkeys’).</p></div></blockquote></div><p>(I introduced spaces/newlines for clearer emphasis)</p><p>And that <em>‘--export-secret-subkeys’</em> is enabled me to get at this stage. But first more, from that book just linked (and it is in the manpage as well), on that command:</p><div class="quotebox"><blockquote><div><p>--export-secret-subkeys<br />&#160; &#160; &#160; &#160; &#160; [...] exports the secret keys instead. The exported keys are<br />&#160; &#160; &#160; &#160; &#160; written to STDOUT or to the file given with option ‘--output’. [...]</p><p>&#160; &#160; &#160; &#160; &#160; [This] command has the special property to render the secret<br />&#160; &#160; &#160; &#160; &#160; part of the primary key useless;</p><p>&#160; &#160; &#160; &#160; &#160; this is a GNU extension to OpenPGP and<br />&#160; &#160; &#160; &#160; &#160; other implementations can not be expected to successfully import such a key.</p><p>&#160; &#160; &#160; &#160; &#160; Its intended use is in generating a full key with an additional signing subkey on<br />&#160; &#160; &#160; &#160; &#160; a dedicated machine. This command then exports the key without the primary<br />&#160; &#160; &#160; &#160; &#160; key [...].</p></div></blockquote></div><p>And here is the GnuPG FAQ entry on this special, and marvelous, OpenPGP use of PGP encryption:</p><p>8.20. How can I use GnuPG in an automated environment?<br /><a href="https://gnupg.org/faq/gnupg-faq.html#automated_use" rel="nofollow">https://gnupg.org/faq/gnupg-faq.html#automated_use</a></p><div class="quotebox"><blockquote><div><p>You should use the <strong>--batch</strong> option.&#160; Don’t bother to use a passphrase because there’s usually no way to store it more securely than on the secret keyring itself.</p><p>The suggested way to create keys for an automated environment is as follows.&#160; First, on a secure machine:</p><p>If you want to do automatic signing, create a signing subkey for your key.&#160; Use the interactive key editing menu by issuing the command:</p><div class="codebox"><pre><code>gpg --edit-key keyID</code></pre></div><p>Enter “addkey” and choose whichever key type best suits your needs.&#160; (If you don’t know which one is best, choose RSA.)</p><p>Make sure that you use a passphrase; this is required by the current implementation to let you export the secret key.</p><p>Run:</p><div class="codebox"><pre><code>gpg --export-secret-subkeys --no-comment newsubkeyID &gt; secring.auto</code></pre></div><p>Copy <strong>secring.auto</strong> and the public keyring to a test directory.</p><p>Change to the test directory.</p><p>Run the command:</p><div class="codebox"><pre><code>gpg --homedir . --edit newsubkeyID</code></pre></div><p>Use the sub-command <strong>passwd</strong> to remove the passphrase from the subkeys. You may also want to remove all unused subkeys by doing <strong>key N</strong> and then <strong>delkey</strong> for each subkey.</p><p>Copy <strong>secring.auto</strong> to the target box somehow.<br />On the target machine, install <strong>secring.auto</strong> as the secret keyring and begin writing scripts that invoke GnuPG.<br />It’s a good idea to install an intrusion detection system so that you will get notice of a successful intrusion.&#160; If that happens, you can revoke all the subkeys installed on that machine and install new subkeys once the machine is secured again.</p></div></blockquote></div><p>This is how my <em><strong>.gnupg/</strong></em> directory looks like</p><div class="codebox"><pre><code>~$ ls -lRa .gnupg
.gnupg:
total 52
drwx------  3 mr mr  4096 2018-03-09 15:22 .
drwxr-xr-x 48 mr mr 20480 2018-03-10 11:07 ..
drwx------  2 mr mr  4096 2018-03-09 04:12 private-keys-v1.d
-rw-------  1 mr mr  4459 2018-03-08 22:23 pubring.gpg
-rw-------  1 mr mr   600 2018-03-10 11:06 random_seed
-rw-r--r--  1 mr mr  6739 2018-03-08 22:37 secring.auto
srwx------  1 mr mr     0 2018-03-09 15:22 S.gpg-agent
srwx------  1 mr mr     0 2018-03-09 15:22 S.gpg-agent.browser
srwx------  1 mr mr     0 2018-03-09 15:22 S.gpg-agent.extra
srwx------  1 mr mr     0 2018-03-09 15:22 S.gpg-agent.ssh
-rw-------  1 mr mr  1200 2018-03-09 04:07 trustdb.gpg

.gnupg/private-keys-v1.d:
total 16
drwx------ 2 mr mr 4096 2018-03-09 04:12 .
drwx------ 3 mr mr 4096 2018-03-09 15:22 ..
-rw------- 1 mr mr 2071 2018-03-09 04:16 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85.key
-rw------- 1 mr mr 1426 2018-03-09 04:15 93C893EA5051CC86BDFC74D0E83CC5AC6F94AEBB.key
~$</code></pre></div><p>And this can show you why it is (very likely) safe for me to keep it on the machine which I connect to internet with:</p><div class="codebox"><pre><code>$ gpg --edit-key 4FBAF0AE
Secret subkeys are available.

pub  rsa4096/EA9884884FBAF0AE
     created: 2014-01-16  expires: 2019-05-19  usage: SC  
     trust: unknown       validity: unknown
ssb  rsa4096/C94689581D481BD5
     created: 2014-01-16  expires: never       usage: E   
ssb  rsa3072/03BAE8E705031008
     created: 2018-03-08  expires: never       usage: S   
[ unknown] (1). Miroslav Rovis (consacrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;
[ revoked] (2)  Miroslav Rovis (consecrated to Heart of Jesus) &lt;miro.rovis@croatiafidelis.hr&gt;

gpg&gt; grip
pub   rsa4096/EA9884884FBAF0AE 2014-01-16 [SC]
      Keygrip: 69DCB3F7DFF03B916BFADC92F522F46A64565D92
sub   rsa4096/C94689581D481BD5 2014-01-16 [E]
      Keygrip: 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85
sub   rsa3072/03BAE8E705031008 2018-03-08 [ S ]
      Keygrip: 93C893EA5051CC86BDFC74D0E83CC5AC6F94AEBB

gpg&gt; quit
~$ ls -l .gnupg/private-keys-v1.d/
total 8
-rw------- 1 mr mr 2071 2018-03-09 04:16 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85.key
-rw------- 1 mr mr 1426 2018-03-09 04:15 93C893EA5051CC86BDFC74D0E83CC5AC6F94AEBB.key
~$</code></pre></div><p>IOW, the prime key secret key is, as it is usually referred to, offlined. Else, the <strong>.gnupg/private-keys-v1.d/</strong> would look similar to this:</p><div class="codebox"><pre><code>-rw------- 1 mr mr 2071 2018-03-09 04:16 61D5243CD1CF616EBE7F2BEE3E830811B6BDCF85.key
-rw------- 1 mr mr XXXX 20XX-XX-09 XX:XX 69DCB3F7DFF03B916BFADC92F522F46A64565D92.key
-rw------- 1 mr mr 1426 2018-03-09 04:15 93C893EA5051CC86BDFC74D0E83CC5AC6F94AEBB.key</code></pre></div><p>(notice the master secret key that <span style="color: red">would be there</span> in the <span style="color: red">unsafe</span> setup, which is often the default)</p><p>I tested this, by sending to myself signed/encrypted messages. It works. By the way, hile I do and will possibly continue to keep using, for maybe another year or so (i.e. until it expires), or maybe less [3], the master key and the encryption subkey, the signing subkey has been only temporary of these days only, while I was learning this knowhow myself, so I&#039;ll try and mark it with a strike-through notation on Devuan Forums.<br />EDIT: Not possible. It only shows literal [ s ] (without spaces).</p><p>That&#039;s all to it. Pity I wasn&#039;t able to do this sooner. I tried, but the couple of hours that I dedicated to it some years ago, wouldn&#039;t suffice for me to phathom these tricks... So many areas in FOSS that need more than just a couple of hours for some degree of true and proper use... (I hope I helped some less advanced users to shorten that time expenditure for themselves.)</p><p>---<br />[1] See for yourself:<br />&#160; &#160; GnuPG programs RBAC policies<br />&#160; &#160; <a href="https://forums.grsecurity.net/viewtopic.php?f=5&amp;t=4662" rel="nofollow">https://forums.grsecurity.net/viewtopic.php?f=5&amp;t=4662</a><br />&#160; &#160; WARNING: how I was doing it is sparsed among a lot of grsec RBAC policies. in brief: essentially I used encrypted partition on a regular USB-stick to host my entire .gnupg/ with secret keys instead of a tailor-made SC-card, and for regular PGP-use without any secret keys, I had a .gnupg/ dir with all the public keys collected in years, and I was always shuffling those.</p><p>[2] The newbie oriented document:<br />&#160; &#160; <a href="https://gnupg.org/gph/en/manual.html" rel="nofollow">https://gnupg.org/gph/en/manual.html</a><br />&#160; &#160; <a href="https://gnupg.org/gph/en/manual.pdf" rel="nofollow">https://gnupg.org/gph/en/manual.pdf</a><br />&#160; &#160; &#160; &#160; has no mention of this technique. It is somewhat advanced, but if a newbie takes her/his privacy seriously, she/he very much needs to be able to deploy it. So if newbies are reading here, they certainly should first get familiar with that introductory manual first.<br />&#160; &#160; However, for most of the information about this safe GnuPG deployment, other than that introductory manual, a newbie needs no other traveling. It&#039;s in the man page:<br />&#160; &#160; </p><div class="codebox"><pre><code>    $ man gnupg
    </code></pre></div><p>&#160; &#160; most of what is also in the gnupg.pdf that I linked above. It however is enough of mumbo-jumbo high brow to deserve the FAQ entry linked above, and the FAQ entry is, while correct, missing some details that regard gnupg-2 <em><strong>.gnupg/private-keys-v1.d/</strong></em> grip-labeled keys. IOW, just following the man page and the FAQ may not suffice for the non-advanced to learn how to deploy this method.<br />&#160; &#160;So, while I&#039;m not very advanced --and will gladly stand corrected by senior member (has already happened, by <span style="color: brown">fsmithred</span> in a major way in at least one of my topic; and that didn&#039;t in the least detract from the usefulness of the topic at all-- I believe this topic might prove useful.</p><p>[3]&#160; Or maybe I decide otherwise; if you are trying to contact me, check up what my key currently is the usual ways.</p><p>[4]&#160; Another note, but I&#039;ll tell the forum webmasters about it. It&#039;s not <strong>[ S ]</strong> in the pasted code, but it is without the spaces. However, the FluxBB complained that I had [ quote ] inside [ s ], and that it wasn&#039;t allowed...<br />Yup! I just got it for the sole one [ S ] (without spaces in the line just above (just the 15 or 20 words back from here, the square brackets around lowercase s didn&#039;t have the spaces around them). I got:</p><div class="quotebox"><cite>FluxBB wrote:</cite><blockquote><div><p>The following errors need to be corrected before the message can be posted:</p><p>&#160; &#160; [ quote ] was opened within [ s ], this is not allowed</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (miroR)]]></author>
			<pubDate>Sat, 10 Mar 2018 11:57:38 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=7907#p7907</guid>
		</item>
	</channel>
</rss>
