最近入手了Yubikey,打算使用yubikey的OTP进行登陆。具体配置如下
- 使用Yubikey Personalization tool进行Yubikey的配置(多图杀狗就略了)
- 通过 Get API Key 获取Yubikey API,样式如下
Client ID: 66888
Secret key: CFFFFFFFFFP6XOiiJZs888888U=
- 在Debian上面安装依赖包
apt-get install libpam-yubico
- 创建yubikey list文件
touch /etc/ssh/authorized_yubikeys
例如我的文件内容是,只有许可的YubiKey IDs是可以被认证。YubiKey ID是Yubikey touch后输出的头12位。
root:v1xxxxxxxxxx:v2xxxxxxxxxx
- 修改/etc/pam.d/sshd文件
注释掉
@include common-auth
在文件尾部增加
auth required pam_yubico.so id=<Client ID> key=<API key> authfile=/etc/ssh/authorized_yubikeys
- 修改/etc/ssh/sshd_config文件,修改
ChallengeResponseAuthentication yes
UsePAM yes
AuthenticationMethods publickey keyboard-interactive:pam
PasswordAuthentication no
PubkeyAuthentication yes
- 重启SSHD
systemctl restart sshd
Written with StackEdit.
Comments