安装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