When you have access to your private key file, use it for quick login. When you are on the go, use your Yubikey OTP and your publickey or .
Tutorial: https://developers.yubico.com/yubico-pam/YubiKey_and_SSH_via_PAM.html
-
Install yubico pam module:
sudo apt-get install libpam-yubico -
Create file
/etc/yubikey_mappingswith the allowed users and their corresponding YubiKey token IDs (first 12 characters of OTP):username1:vvabcdefghij username2:vvabcdefghij -
Get a new API-id from https://upgrade.yubico.com/getapikey/ and adjust file
/etc/pam.d/sshdto request YubiKey OTP. Paste this line at the very beginning of the file:auth required pam_yubico.so id=12345 key=<PASSWORD> authfile=/etc/yubikey_mappingsYou can add the
debugargument as stated here: https://developers.yubico.com/yubico-pam/Manuals/pam_yubico.8.html -
In
/etc/ssh/sshd_configset the following configurations:PermitRootLogin no PasswordAuthentication no ChallengeResponseAuthentication yes UsePAM yesPermitRootLogin nois set just for security reasons.ChallengeResponseAuthentication yesandUsePAM yeswill ask for YubiKey and then for password.- One could also set
PasswordAuthentication yesandChallengeResponseAuthentication no, which would take Password+OTP as one single password string, without explicitly asking for YubiKey.
- Uncomment
@include common-authin/etc/pam.d/sshd - Ensure
AuthenticationMethods publickey,keyboard-interactiveis set in/etc/ssh/sshd_config