您当前的位置:首页 > 学海无涯 > 信息安全网站首页信息安全
Centos SSH使用谷歌二次验证登陆
发布时间:2021-02-24作者:♂逸風★淩軒
一、安装依赖
yum -y install autoconf automake libtool pam-devel
二、编译装二维码支持(失败不影响)
git clone https://github.com/fukuchi/libqrencode.git cd libqrencode ./autogen.sh make -j32 make install
三、编译装本体
#注意项目名改变了,变成了单独一个项目,不再在google-authenticator这个里
git clone https://github.com/google/google-authenticator-libpam.git cd google-authenticator-libpam ./bootstrap.sh ./configure make -j32 make install
#此时将会生成文件
#/usr/local/lib/security/pam_google_authenticator.so
#/usr/local/lib/security/pam_google_authenticator.la
#还会生成一个命令
# google-authenticator
#这是让你到home目录里去用的
四、修改配置
修改PAM配置
vi /etc/pam.d/sshd
auth required pam_sepermit.so
auth substack password-auth
auth required /usr/local/lib/security/pam_google_authenticator.so
...
#注意:放到第一行去就是先输入动态口令,再输入密码。
修改 sshd 的配置文件
vi /etc/ssh/sshd_config
修改为
...
ChallengeResponseAuthentication yes
...
重启sshd
systemctl restart sshd.service
五、用户设置
去home目录运行(需要本机执行)
google-authenticator
按提示按需选择(默认之后出现的几个选择输入的地方,全输入y),里面显示的巨大二维码用app扫下。出现的5个备忘号码,要记好。
使用Xshell登陆:
重新登录就完事了。
关键字词:SSH,二次验证,登陆,安全

下一篇:返回列表