Tags

arm64 blacklistd bluetooth cu dns dovecot envsubst esp8266 filter freebsd ipfw lets_encrypt opensmtpd python shell ssl template tls unbound yubikey

Powered by

blOg
maRkdown
awK
shEll

21/05/2022

[ yubikey ]

202205210800 yubikey

FreeBSD 13.1, OpenSSH et Yubikey

Cette nouvelle mouture de FreeBSD vient entre autre avec une mise à jour d'OpenSSH et ça cause FIDO/U2F. Il serait temps d'utiliser enfin cette Yubikey qui traine sur mon porte-clefs depuis des lustres:

$ dmesg | tail -n 6
ugen0.3: <Yubico YubiKey OTP+FIDO+CCID> at usbus0
ukbd1 on uhub0
ukbd1: <Yubico YubiKey OTP+FIDO+CCID, class 0/0, rev 2.00/5.12, addr 7> on usbus0
kbd3 at ukbd1
uhid1 on uhub0
uhid1: <Yubico YubiKey OTP+FIDO+CCID, class 0/0, rev 2.00/5.12, addr 7> on usbus0

On va s'éparger du temps et des cheveux avec ce petit paquet kivabien:

$ doas pkg install u2f-devd
$ doas service devd restart
$ doas pw groupmod u2f -m MonLogin
[ snip déco/reco pour que le nouveau groupe soit pris en compte ]
$ ssh-keygen -t ed25519-sk
Generating public/private ed25519-sk key pair.
You may need to touch your authenticator to authorize key generation.
Key enrollment failed: requested feature not supported

Pas de soucis, c'est juste que le firmware de la clef est trop vieux pour utiliser ed25519-sk. Avec ecdsa-sk:

$ ssh-keygen -t ecdsa-sk
Generating public/private ecdsa-sk key pair.
You may need to touch your authenticator to authorize key generation.
[ la clef clignotte et attend une pression ]
Enter file in which to save the key (/home/MonLogin/.ssh/id_ecdsa_sk): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/MonLogin/.ssh/id_ecdsa_sk
Your public key has been saved in /home/MonLogin/.ssh/id_ecdsa_sk.pub$ ssh-keygen -t ecdsa-sk
...

Reste à déployer cette clef:

$ cat .ssh/id_ecdsa_sk.pub | ssh MonServeur "cat >> .ssh/authorized_keys"
$ unsetenv SSH_AUTH_SOCK
$ ssh -i .ssh/id_ecdsa_sk MonServeur
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
[ la clef clignotte et attend une pression ]
User presence confirmed
Last login: Sat May 21 10:07:59 2022 from dd.bsdsx.fr
...

Parfois la clef ne semble pas répondre:

$ ssh -i .ssh/id_ecdsa_sk nuc date
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
User presence confirmed
sam. 21 mai 2022 10:17:09 CEST
$ ssh -i .ssh/id_ecdsa_sk nuc date
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
User presence confirmed
sam. 21 mai 2022 10:17:14 CEST
$ ssh -i .ssh/id_ecdsa_sk nuc date
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
User presence confirmed
sam. 21 mai 2022 10:17:20 CEST
$ ssh -i .ssh/id_ecdsa_sk nuc 
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
[ la clef ne clignotte pas ]

Pas grand chose à faire:

^C
$ ssh -i .ssh/id_ecdsa_sk nuc
Confirm user presence for key ECDSA-SK SHA256:gkWxSHUxZjN5Q6svr51Mi0N+vMc051YPwXo7L1JkaQw
User presence confirmed
Last login: Sat May 21 10:14:38 2022 from dd.bsdsx.fr

Lien utile: https://cryptsus.com/blog/how-to-configure-openssh-with-yubikey-security-keys-u2f-otp-authentication-ed25519-sk-ecdsa-sk-on-ubuntu-18.04.html (anglais)

Commentaires: https://github.com/bsdsx/blog_posts/issues/14


Lien vers ce billet