手机上安装Google身份验证器
安装地址:http://www.wandoujia.com/apps/com.google.android.apps.authenticator2
注意:机器上一定要关闭selinux
1、安装依赖:
yum-yinstallgccmakepam-devellibpng-devellibtoolwgetgit
2、开启EPEL源
yum–enablerepo=epel
3、或者直接安装EPEL源RPM包
# CentOS 6
rpm-Uvhhttp://mirrors.ustc.edu.cn/fedora/epel/epel-release-latest-6.noarch.rpm
# CentOS 7
rpm-Uvhhttp://mirrors.ustc.edu.cn/fedora/epel/epel-release-latest-7.noarch.rpm
4、安装Qrencode,谷歌身份验证器需要调用该程序生成二维码并显示
yuminstall-yqrencode
5、安装谷歌身份验证器
gitclonehttps://github.com/google/google-authenticator-libpam.git cdgoogle-authenticator-libpam/
编译并安装
./bootstrap.sh ./configure--prefix=/usr/local/google-authenticator make&&makeinstall
复制google 身份验证器pam模块到系统下
cp/usr/local/google-authenticator/lib/security/pam_google_authenticator.so/lib64/security/
6、配置/etc/pam.d/sshd
在
authincludepassword-auth
authrequiredpam_google_authenticator.so
注意顺序:谷歌认证要在password-auth上面
[root@localhost ~]# cat /etc/pam.d/sshd
#%PAM-1.0 authrequiredpam_sepermit.so authrequiredpam_google_authenticator.so authincludepassword-auth accountrequiredpam_nologin.so accountincludepassword-auth passwordincludepassword-auth #pam_selinux.socloseshouldbethefirstsessionrule sessionrequiredpam_selinux.soclose sessionrequiredpam_loginuid.so #pam_selinux.soopenshouldonlybefollowedbysessionstobeexecutedintheusercontext sessionrequiredpam_selinux.soopenenv_params sessionoptionalpam_keyinit.soforcerevoke sessionincludepassword-auth
7、修改SSH服务配置/etc/ssh/sshd_config
将ChallengeResponseAuthentication no改成yes,即
ChallengeResponseAuthenticationyes
8、启用 Google Authenticator
./google-authenticator
Doyouwantauthenticationtokenstobetime-based(y/n)y
# 是否开启基于时间的认证,Y, 测试下来,如果选N,则手机上的验证码不会自动更新,使用一次后就算手动更新了验证码也无法登录。
后面一路都是选择y,就可以了
注意保存好上面的5个emergency scratch codes,如果手机上的验证码不通过,可以使用上面的这个验证码,每次使用后就失效了。
linux登录客户端的设置
参考文档:
https://shenyu.me/2016/09/05/centos-google-authenticator.html
https://www.sulabs.net/?p=802
原文地址:https://www.jb51.cc/centos/374387.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。