<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>IT notes - gpg</title>
    <subtitle>DBRE, AWS platform engineering, PostgreSQL, Linux, FreeBSD, and Rust reference notes.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://nbari.com/tags/gpg/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://nbari.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2022-05-28T15:00:32+00:00</updated>
    <id>https://nbari.com/tags/gpg/atom.xml</id>
    <entry xml:lang="en">
        <title>yubikey</title>
        <published>2022-05-28T15:00:32+00:00</published>
        <updated>2022-05-28T15:00:32+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://nbari.com/yubikey/"/>
        <id>https://nbari.com/yubikey/</id>
        
        <content type="html" xml:base="https://nbari.com/yubikey/">&lt;p&gt;Install ykman:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;brew&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; install ykman&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Configure your 2 slot for static password:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; otp static&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --keyboard-layout US&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will prompt you to enter the password you want to store in the slot but default adding the enter key at the end of the password. If you want to avoid that just add &lt;code&gt;--no-enter&lt;/code&gt; flag, for example you can use:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; otp static&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --keyboard-layout US&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;your password&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --no-enter&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;--keyboard-layout US&lt;/code&gt; is to prevent getting &lt;code&gt;Error: Unsupported character: xxx&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can also use the &lt;code&gt;--pacing&lt;/code&gt; flag to add a delay between each character, for example:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; otp settings&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --pacing&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 60&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;reset-pin&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#reset-pin&quot; aria-label=&quot;Anchor link for: reset-pin&quot;&gt;🔗&lt;/a&gt;reset pin&lt;/h2&gt;
&lt;p&gt;To reset all data:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; ykman piv reset&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;WARNING!&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; This will delete all stored PIV data and restore factory settings. Proceed?&lt;/span&gt;&lt;span&gt; [y/N]: y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;Resetting&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; PIV data...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;Success!&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; All PIV data have been cleared from the YubiKey.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;Your&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; YubiKey now has the default PIN, PUK and Management Key:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;        PIN:&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt;    123456&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;        PUK:&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt;    12345678&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;        Management&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; Key:&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 010203040506070801020304050607080102030405060708&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the PIN from 123456 to 654321:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; piv access change-pin --pin&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 123456&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --new-pin&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 654321&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change the PUK&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; piv change-puk&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Generate a random management key and store it on the device, protected with the PIN.&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; piv change-management-key --generate --protect&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;gpg&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#gpg&quot; aria-label=&quot;Anchor link for: gpg&quot;&gt;🔗&lt;/a&gt;GPG&lt;/h2&gt;
&lt;p&gt;To reset all GPG data:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ykman&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; openpgp reset&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set the Admin and pin using:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; gpg --edit-card&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpg/card&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; admin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;Admin&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; commands are allowed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpg/card&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;passwd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To use the key in another system just import the public key and trust it:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; curl -sSL https://github.com/nbari.gpg&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-12&quot;&gt; gpg&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --import&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; gpg --edit-key nbari@tequila.io&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;trust&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;save&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart the gpg-agent:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpgconf&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --kill gpg-agent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpgconf&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --kill scdaemon&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Remove password from gpg key to import it to yubikey.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Check: https://developers.yubico.com/PGP/Importing_keys.html&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>GPG RemoteForward</title>
        <published>2021-12-08T20:56:49+01:00</published>
        <updated>2021-12-08T20:56:49+01:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://nbari.com/gpg-remoteforward/"/>
        <id>https://nbari.com/gpg-remoteforward/</id>
        
        <content type="html" xml:base="https://nbari.com/gpg-remoteforward/">&lt;p&gt;To Forward your SSH session if using a Yubikey and &lt;code&gt;gpg-agent&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;For example to connect from a MacOS to a Linux VM:&lt;/p&gt;
&lt;p&gt;On the client, add this to your &lt;code&gt;~/.ssh/config&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;Host&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; foo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;    Hostname&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; X.X.X.X&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;    ForwardAgent&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;    RemoteForward&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; /run/user/1000/gnupg/S.gpg-agent     /Users/monkey/.gnupg/S.gpg-agent.extra&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;    RemoteForward&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; /run/user/1000/gnupg/S.gpg-agent.ssh /Users/monkey/.gnupg/S.gpg-agent.extra.ssh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-3&quot;&gt;                            (&lt;/span&gt;&lt;span class=&quot;z-12&quot;&gt;remote&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; socket&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;)                  (&lt;/span&gt;&lt;span&gt;l&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;ocal socket&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To find the local socket in your mac/client do:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpgconf&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --list-dirs agent-extra-socket&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To find the remove socket, in the Linux VM, do:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpgconf&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --list-dirs agent-socket&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the remote host (the Linux VM) in &lt;code&gt;.bashrc&lt;/code&gt; I have:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpgconf&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --create-socketdir&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If can&#39;t login, remove the socket: &lt;code&gt;rm -f /run/user/1000/gnupg/S.gpg-agent&lt;/code&gt;, if posible add this to the /etc/ssh/sshd_config: &lt;code&gt;StreamLocalBindUnlink yes&lt;/code&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Optional If you do not have root access to the remote machine to edit /etc/ssh/sshd_config, you will need to remove the socket (located at gpgconf --list-dir agent-socket) on the remote machine before forwarding works. For example, rm /run/user/1000/gnupg/S.gpg-agent - https://github.com/drduh/YubiKey-Guide#remote-machines-gpg-agent-forwarding&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Add your public key to the remove host:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpg&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -a -o pub.key --export your@key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the remote host import your key and trust it:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpg&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --import pub.key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;gpg&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --edit-key KEYID&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;trust&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;save&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could also use:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -R /run/user/1000/gnupg/S.gpg-agent:/Users/monkey/.gnupg/S.gpg-agent.extra -o&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;StreamLocalBindUnlink=yes&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; user@x.x.x.x&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the remote host test with something like:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -T git@github.com&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also you could list all your current keys with:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-12&quot;&gt;ssh-add&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; -L&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;scdaemon-conf&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#scdaemon-conf&quot; aria-label=&quot;Anchor link for: scdaemon-conf&quot;&gt;🔗&lt;/a&gt;scdaemon.conf&lt;/h2&gt;
&lt;p&gt;In macOS, you can use the following &lt;code&gt;~/.gnupg/scdaemon.conf&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pcsc-driver /System/Library/Frameworks/PCSC.framework/PCSC&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;disable-ccid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;log-file /tmp/scdaemon.log&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In Linux:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pcsc-driver /usr/lib/libpcsclite.so&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;disable-ccid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;log-file /tmp/scdaemon.log&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;you may need to install &lt;code&gt;libusb-compat&lt;/code&gt; to use &lt;code&gt;libpcsclite.so&lt;/code&gt; on some systems&lt;/p&gt;
&lt;/blockquote&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>gpg: selecting card failed: Operation not supported by device</title>
        <published>2021-04-27T20:24:49+02:00</published>
        <updated>2021-04-27T20:24:49+02:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://nbari.com/gpg-selecting-card-failed-operation-not-supported-by-device/"/>
        <id>https://nbari.com/gpg-selecting-card-failed-operation-not-supported-by-device/</id>
        
        <content type="html" xml:base="https://nbari.com/gpg-selecting-card-failed-operation-not-supported-by-device/">&lt;p&gt;If using a yubikey and getting this:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg: selecting card failed: Operation not supported by device&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg: OpenPGP card not available: Operation not supported by device&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add to &lt;code&gt;~/.gnupg/scdaemon.conf&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;disable-ccid&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To debug you could use:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;reader-port Yubico Yubi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;debug-all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;debug-level guru&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;disable-ccid&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;log-file /tmp/scd.log&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>gpg</title>
        <published>2018-02-27T12:33:49+01:00</published>
        <updated>2018-02-27T12:33:49+01:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://nbari.com/gpg/"/>
        <id>https://nbari.com/gpg/</id>
        
        <content type="html" xml:base="https://nbari.com/gpg/">&lt;p&gt;Install gpg on macOS:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;brew install gnupg pinentry-mac&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;if required restart gpg-agent with &lt;code&gt;gpgconf --kill gpg-agent&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To create a &lt;code&gt;gpg&lt;/code&gt; key in batch mode, create a file named &lt;code&gt;gpg-key-script&lt;/code&gt; with
this value:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Key-Type: EDDSA&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Key-Curve: Ed25519&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Key-Usage: sign auth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Subkey-Type: ECDH&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Subkey-Curve: Cv25519&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Subkey-Usage: encrypt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Name-Real: your name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Name-Comment: your comment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Name-Email: your@email&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Expire-Date: 2y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next you could do something like:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ gpg --homedir /salt/gpgkeys --batch --gen-key gen-key-script&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To extend the expiration date of a key:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ gpg --homedir /salt/gpgkeys --edit-key your@email&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg&amp;gt; expire&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Please specify how long the key should be valid.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        0 = key does not expire&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     &amp;lt;n&amp;gt;  = key expires in n days&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     &amp;lt;n&amp;gt;w = key expires in n weeks&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     &amp;lt;n&amp;gt;m = key expires in n months&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;     &amp;lt;n&amp;gt;y = key expires in n years&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For example to extend 1 year:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Your selection? 1y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg&amp;gt; save&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;backup-private-key&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#backup-private-key&quot; aria-label=&quot;Anchor link for: backup-private-key&quot;&gt;🔗&lt;/a&gt;Backup private key&lt;/h2&gt;
&lt;p&gt;To save the private key to a file:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg --homedir /salt/gpgkeys -a --export-secret-keys &amp;gt; private.key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;No need to export the public key&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To import the pair of keys later just do:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg --import private.key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;if can&#39;t paste the pssphrase:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-2&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt;%s&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; password&lt;/span&gt;&lt;span class=&quot;z-3&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-12&quot;&gt; gpg&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --batch --yes --pinentry-mode loopback --passphrase-fd&lt;/span&gt;&lt;span class=&quot;z-10&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;z-7&quot;&gt; --import key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&quot;rngd-linux&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#rngd-linux&quot; aria-label=&quot;Anchor link for: rngd-linux&quot;&gt;🔗&lt;/a&gt;rngd (linux)&lt;/h1&gt;
&lt;p&gt;If you don&#39;t have an source of entropy it may take a while to generate the keys,
if you are in a linux system you could install &lt;code&gt;rngd&lt;/code&gt; or (&lt;code&gt;rng-tools&lt;/code&gt;) and then type:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# rngd -v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Unable to open file: /dev/tpm0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;can&amp;#39;t open any entropy source&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Maybe RNG device modules are not loaded&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To start &lt;code&gt;rngd&lt;/code&gt; using &lt;code&gt;/dev/urandom&lt;/code&gt;, do this:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# cp /usr/lib/systemd/system/rngd.service /etc/systemd/system&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edit &lt;code&gt;/etc/systemd/system/rngd.service&lt;/code&gt; and replace the line starting with &lt;code&gt;ExecStart&lt;/code&gt; with:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ExecStart=/sbin/rngd -f -r /dev/urandom&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Reload systemd:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# systemctl daemon-reload&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And restart &lt;code&gt;rngd&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# systemctl restart rngd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&quot;using-gpg-as-ssh&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#using-gpg-as-ssh&quot; aria-label=&quot;Anchor link for: using-gpg-as-ssh&quot;&gt;🔗&lt;/a&gt;using gpg as ssh&lt;/h1&gt;
&lt;p&gt;You need to install &lt;code&gt;monkeysphere&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ brew install monkeysphere&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To remove password from a subkey &quot;authentication [A]&quot; and convert later to ssh id_rsa:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ gpg --export-secret-subkey F6C7D705867D430! | gpg --home /tmp/x --import&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ gpg --home /tmp/x --change-passphrase F6C7D705867D430!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ gpg --home /tmp/x --export-secret-subkey F6C7D705867D430! | openpgp2ssh F6C7D705867D430  &amp;gt; /tmp/naked-id_rsa&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then to add password again to the key:&lt;/p&gt;
&lt;pre class=&quot;giallo z-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;$ ssh-keygen -f /tmp/naked-id_rsa -p&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        
    </entry>
</feed>
