Skip to content

Instantly share code, notes, and snippets.

@awoimbee
Last active May 5, 2024 15:33
Show Gist options
  • Save awoimbee/8312ab17979b0b89fea53ec98f60c805 to your computer and use it in GitHub Desktop.
Save awoimbee/8312ab17979b0b89fea53ec98f60c805 to your computer and use it in GitHub Desktop.
OpenSuse Tumbleweed sudo via Yubikey

Sources:

Commands:

# Generate the u2f keys/config
pamu2fcfg -u $(whoami) -opam://$HOSTNAME -ipam://$HOSTNAME > ~/u2f_keys
pamu2fcfg -u root -opam://$HOSTNAME -ipam://$HOSTNAME >> ~/u2f_keys
sudo -i
mkdir -p /etc/Yubico/
mv ~/u2f_keys /etc/Yubico/
grep -v "pam_u2f.so" /usr/lib/pam.d/common-auth \
  | sed "/auth\s*required\s*pam_env.so/i auth    sufficient      pam_u2f.so origin=pam://$HOSTNAME appid=pam://$HOSTNAME authfile=/etc/Yubico/u2f_keys cue [cue_prompt=🔐 Waiting for U2F key...]" \
  > tmp_common_auth
rm /etc/pam.d/common-auth
mv tmp_common_auth /etc/pam.d/common-auth

/etc/pam.d/common-auth should look like (replace $HOSTNAME by its value):

# [...]
auth    sufficient      pam_u2f.so origin=pam://$HOSTNAME appid=pam://$HOSTNAME authfile=/etc/Yubico/u2f_keys cue [cue_prompt=🔐 Waiting for U2F key...]
auth	required	pam_env.so
auth	required	pam_unix.so	try_first_pass
# [...]

Et voilà, you can now sudo without typing your passwords, note that this also works with polkit (gui sudo prompt) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment