CentOS 使用 Google Authenticator 登录验证
Google Authentication 项目 包含了多个手机平台的一次性验证码生成器的实现,以及一个可插拔的验证认证模块(PAM)。这些实现支持基于 HMAC 的一次性验证码(HOTP)算法(RFC 4226)和基于时间的一次性验证码(TOTP)算法(RFC 6238)。
下面将在 CentOS 上安装并使用 Google Authenticator 做登录的身份验证,当前系统的版本为
CentOS Linux release 7.6 (Core)
安装 Google Authenticator PAM module
-
确保
ntpd
已安装并正常运行运行yum install -y ntpdate 在计划任务中增加 1 3 * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1
ntpdate
是用来自动同步时间的程序,设置明天同步时间 -
安装一些接下去会用到的组件
yum install -y git make gcc libtool pam-devel
-
编译安装 Google Authenticator PAM module
git clone https://github.com/google/google-authenticator-libpam ./bootstrap.sh ./configure make make install ln -s /usr/local/lib/security/pam_google_authenticator.so /usr/lib64/security/
配置 SSH 服务
打开 /etc/ssh/sshd_config
文件
vim /etc/ssh/sshd_config
修改下面字段的配置
ChallengeResponseAuthen