YubiKey bash setup

ยท 133 words ยท 1 minute read

From Wikipedia: The YubiKey is a hardware authentication device manufactured by Yubico to protect access to computers, networks, and online services that supports one-time passwords (OTP), public-key cryptography, and authentication, and the Universal 2nd Factor (U2F) and FIDO2 protocols developed by the FIDO Alliance.

To get up and running on a new machine with minimal fuss.

.bashrc ๐Ÿ”—

When you are not logged in via SSH, start the gpg-agent. Copy and paste into your terminal to append the configuration to your current .bashrc.

cat <<EOF >> ~/.bashrc
if [[ -z "\$SSH_CONNECTION" ]]
then
  export SSH_AUTH_SOCK=\$(gpgconf --list-dirs agent-ssh-socket)
  gpgconf --launch gpg-agent
fi
EOF

.gnupg/gpg-agent.conf ๐Ÿ”—

Configure the gpg-agent to enable SSH support. Copy and paste into your terminal to overwrites the file .gnupg/gpg-agent.conf with this configuration.

cat <<EOF > ~/.gnupg/gpg-agent.conf
enable-ssh-support
default-cache-ttl 600
max-cache-ttl 7200
EOF