CentOS7启用双因子认证

2022-10-27 15:27:32 浏览数 (1)

安装google身份验证器

代码语言:javascript复制
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker git automake libtool pam-devel epel-release
 
git clone https://github.com/google/google-authenticator-libpam.git
 
cd google-authenticator-libpam/
 
./bootstrap.sh
 
./configure && make && make install
 
cp /usr/local/lib/security/pam_google_authenticator.so /lib64/security/

手机上下载google身份验证器

生成验证密钥

代码语言:javascript复制
[root@vm212664 ~]# yum -y install google-authenticator
[root@vm212664 ~]# google-authenticator

会出现一个二维码,在手机上打开google身份验证器,扫描该二维码

修改配置

vim /etc/pam.d/sshd

代码语言:javascript复制
auth required pam_google_authenticator.so

vim /etc/ssh/sshd_config

代码语言:javascript复制
ChallengeResponseAuthentication yes

重启sshd服务

代码语言:javascript复制
systemctl restart sshd

0 人点赞