Install supporting software
sudo apt-add-repository ppa:yubico/stable
sudo apt-get update
sudo apt-get install scdaemon -y
sudo apt-get install python-setuptools python-crypto python-pyscard python-pyside pyside-tools libykpers-1-1 pcscd -y
sudo apt-get install yubioath-desktop yubikey-personalization yubikey-personalization-gui yubikey-manager -y
Insert Yubikey and Generate key
gpg --card-edit
gpg/card> admin
gpg/card> generate
gpg/card> quit
export and backup the public keys, because the Yubikey only stores the private portion of the key
gpg --armor --export $KEYID > mykey.pub
Require touching the Yubikey button to authenticate, sign, or encrypt:
ykman openpgp touch aut on
ykman openpgp touch sig on
ykman openpgp touch enc on
Change the pin
gpg --card-edit
gpg/card> admin
gpg/card> passwd
gpg/card> quit
Change yubikey information
gpg --card-edit
gpg/card> name
gpg/card> lang
gpg/card> quit
References: