These are mainly personal notes to myself about doing stuff I have done or need to do and will probably forget exactly how to do later. Always look up what things mean before doing it.

Yubikey - Readding Smartcard PGP keys for SSH

If you use Yubikey that stores a PGP authentication key for ssh, you likely will need to add it to another computer later. This is just a quick list of things you need.

# Required packages

sudo apt install gnupg libpcsclite1 pcscd scdaemon

# Check card, fetch the key, and trust

gpg --card-status
gpg/card> fetch
gpg --list-secret-keys --with-subkey-fingerprint
gpg --edit-key XXXX
gpg> trust
5 = I trust ultimately

# Setup gpg-agent and ssh-agent

echo "enable-ssh-support" >> $HOME/.gnupg/gpg-agent.conf
echo 'export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)' >> $HOME/.bashrc
source .bashrc

# Reload gpg-agent

gpgconf --reload gpg-agent

# Check the card is now cached

gpg-connect-agent 'keyinfo --list' /bye
ssh-add -l

# If needed, export the [A] authentication subkey for ssh

gpg --list-secret-keys --with-subkey-fingerprint
gpg --export-ssh-key XXX