通过Google身份验证登录linux服务器

608次阅读
没有评论

我们可以通过安装 Google 身份验证器登录服务器,这样即使密码泄露没有验证码别人也进入不了服务器

环境准备

1. 安装需要的软件

yum -y install gcc make pam-devel libpng-devel libtool wget git

2. 下载 google-authenticator-libpam

git https://github.com/google/google-authenticator-libpam.git

3. 安装编译

cd google-authenticator-libpam/
./bootstrap.sh

通过 Google 身份验证登录 linux 服务器

通过 Google 身份验证登录 linux 服务器

./configure && make && make install

编译成功会在目录生成文件

ll /usr/local/lib/security/pam_google_authenticator.so

通过 Google 身份验证登录 linux 服务器

复制文件到 lib64

cp /usr/local/lib/security/pam_google_authenticator.so /lib64/security/

4. 配置 /etc/pam.d/sshd

添加下图内容后

auth       required     pam_google_authenticator.so

通过 Google 身份验证登录 linux 服务器

5. 更改 sshd 配置文件 /etc/ssh/sshd_config

通过 Google 身份验证登录 linux 服务器

6. 重启 sshd

systemctl restart sshd

7. 切换到需要验证的用户如 root 用户

google-authenticator

通过 Google 身份验证登录 linux 服务器

使用手机 google 身份验证器扫描二维码进行登录

通过 Google 身份验证登录 linux 服务器

8.xshell 配置

通过 Google 身份验证登录 linux 服务器

9. 登录服务器

输入 google 身份验证码

通过 Google 身份验证登录 linux 服务器

输入系统密码

通过 Google 身份验证登录 linux 服务器

登录成功!

正文完
 0
ddn
版权声明:本站原创文章,由 ddn 2017-05-12发表,共计1124字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)