Using Yubikey for SSH on OpenSuse Tumbleweed
OpenSuse Tumbleweed comes mostly ready for use with YubiKey (Assuming you have already configured your Yubikey before).
All you need to do is a few simple configuration:
Create
.gnupg
directory under your home directory andcd
into itmkdir ~/.gnupgp && cd $_
Create
gpg-agent.conf
to store the requiredgpg-agent
settingsvim gpg-agent.conf
Tell
gpg-agent
whichtty
,SSH_AUTH_SOCK
, and program to use to ask for PIN by adding following configuration intogpg-agent.conf
and saving the file:
enable-ssh-support # gpg-agent will only set the SSH_AUTH_SOCK variable if this flag is set
ttyname $GPG_TTY # Use the tty set in $GPG_TTY enviroment variable
pinentry-program /usr/bin/pinentry-curses # Use this program to ask for pin
- Tell your shell (bash, zsh etc) to set the
SSH_AUTH_SOCK
andGPG_TTY
forgpg-agent
to use, and then launchgpg-agent
if it’s not already started by adding the following your shell’s rc file (~/.bashrc
for bash,~/.zshrc
for zsh):
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpg-connect-agent updatestartuptty /bye > /dev/null
- Open a new shell to make sure the new
rc
file is loaded, and then runssh [email protected]
If you have added your public key to your github, a prompt will pop up in shell and asks for your pin:
And upon successful login to Github, you’ll see a welcome message:Done.