欢迎光临散文网 会员登陆 & 注册

Google Authenticator实现Linux用户登录双认证双重认证

2023-06-14 20:13 作者:movno1  | 我要投稿

1、安装这个

yum install epel-release -y

或者

dnf epel-release -y

 

2、安装这个

yum install google-authenticator -y

或者

dnf install google-authenticator -y

 

 

3、安装这个(用于显示二维码)                                                                         

yum install qrencode-libs -y

 

4、运行这个

google-authenticator

5、

5.1、添加谷歌身份验证器PAM模块

在vi /etc/pam.d/sshd文件最后添加谷歌身份验证器PAM模块配置:

auth required pam_google_authenticator.so

或使用如下命令在/etc/pam.d/sshd文件添加认证模块:

echo "auth required pam_google_authenticator.so" >>/etc/pam.d/sshd

5.2配置挑战式密码认证

需要在这个目录下面增加一下,否则登录一直报错,almalinux系统是这样,其他系统暂时没有测试。

sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config.d/50-redhat.conf

5.3

systemctl restart sshd


5.4下面两个问题是解决,登录的时候报错(核心内容)

主要是因为SELinux不允许写入

sudo semanage fcontext -a -t ssh_home_t "/root/.google_authenticator"

sudo semanage fcontext -a -t ssh_home_t "/root"

 

sudo restorecon -v /root/.google_authenticator



下面2个是临时设置权限,重启后失效(不需要使用)

sudo chcon -t ssh_home_t /root/.google_authenticator

sudo chcon -t ssh_home_t /root


Google Authenticator实现Linux用户登录双认证双重认证的评论 (共 条)

分享到微博请遵守国家法律