一、安装依赖包

软件包可以在这个地址下载:https://pan.baidu.com/s/1r0CmwbtCfNiBqU9rh_TxtA

yum -y install pam-devel
tar jxf libpam-google-authenticator-1.0-source.tar.bz2
cd libpam-google-authenticator-1.0
make && make install
[root@chunkserver1 ~]# google-authenticator

Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@chunkserver1%3Fsecret%3D4WPHQZ546UTLMBYP
Your new secret key is: 4WPHQZ546UTLMBYP
Your verification code is 856950
Your emergency scratch codes are:
37193134
39632359
18788141
32566498
89776977
#五个码用于在取不到或错的验证码有错时,用于应急用的。不过每个只能用一次,不能重复使用。
Do you want me to update your "/root/.google_authenticator" file (y/n) y Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n
#选择是否开启时间容错。如果客户端设备具有很好的同时间服务器同步功能,建议此处选择n。如果客户端设备(手机、ipad等)不具有很好的同ntp时间同步的功能,可以设为y —— 即开启时间容错。 If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y

 

二、编辑文件cat /etc/pam.d/sshd 在第一行添加

auth required pam_google_authenticator.so

编辑/etc/ssh/sshd_config 文件

ChallengeResponseAuthentication no
把上面配置改成
ChallengeResponseAuthentication yes

service sshd restart重启ssh服务生效。

三、客户端安卓手机下载身份验证器工具,打开软件,手动输入账户(账户名称随便写) 密钥输入上面运行google-authenticator 生成 的此密钥4WPHQZ546UTLMBYP

四、测试:打开xshell连接,在弹出的输入密码界面选择使用键盘输入用户身份验证,然后输入手机上身份验证器生成的每60秒换一个的密钥

五、注意:服务器上要关闭selinux,否则会登录不了

1、如果命使用SecureCRT客户端登录时,需要在 连接——属性——连接——ssh2——"鉴权/authenicaion" 中将 "键盘交互/keyboard Interactive" 调到第一位。不然连接会出错。

2、以上安全配置对于ssh密钥认证方式进行的登录无效——即在pam配置中增加上面的配置后,通过密钥认证时不会要求输入验证码 。

Google Authenticator加强ssh安全的更多相关文章

  1. 【Linux】使用Google Authenticator 实现ssh登录双因素认证

    一般来说,使用ssh远程登录服务器,只需要输入账号和密码,显然这种方式不是很安全.为了安全着想,可以使用GoogleAuthenticator(谷歌身份验证器),以便在账号和密码之间再增加一个验证码, ...

  2. Linux下使用Google Authenticator配置SSH登录动态验证码

    1.一般ssh登录服务器,只需要输入账号和密码.2.本教程的目的:在账号和密码之间再增加一个验证码,只有输入正确的验证码之后,再输入密码才能登录.这样就增强了ssh登录的安全性.3.账号.验证码.密码 ...

  3. Linux 利用Google Authenticator实现ssh登录双因素认证

    1.介绍 双因素认证:双因素身份认证就是通过你所知道再加上你所能拥有的这二个要素组合到一起才能发挥作用的身份认证系统.双因素认证是一种采用时间同步技术的系统,采用了基于时间.事件和密钥三变量而产生的一 ...

  4. centos6实现基于google authenticator 的ssh登录二次验证

    1.手机安装google身份验证器,在浏览器搜索身份验证器安装即可. centos6安装所需要的软件--- google-authenticator 2.查看这个包生成的所有文件和命令 3.输入goo ...

  5. SSH + Google Authenticator 安全加固

    1. SSH连接 Secure Shell(安全外壳协议,简称SSH)是一种加密的网络传输协议,可在不安全的网络中为网络服务提供安全的传输环境.SSH通过在网络中创建安全隧道来实现SSH客户端与服务器 ...

  6. Linux下部署SSH登录时的二次身份验证环境记录(利用Google Authenticator)

    一般来说,使用ssh远程登录服务器,只需要输入账号和密码,显然这种方式不是很安全.为了安全着想,可以使用GoogleAuthenticator(谷歌身份验证器),以便在账号和密码之间再增加一个验证码, ...

  7. ssh密码登录+ Google Authenticator 实现双向认证

    通常我们直接通过ssh输入密码连接服务器,但这样很容易出现暴力破解情况,所以我们可以结合google的动态认证+ssh密码,这样能够大大的提升登陆的安全. 简单来说,就是当用户通过ssh登陆系统时,先 ...

  8. Linux 之 利用Google Authenticator实现用户双因素认证

    一.介绍:什么是双因素认证 双因素身份认证就是通过你所知道再加上你所能拥有的这二个要素组合到一起才能发挥作用的身份认证系统.双因素认证是一种采用时间同步技术的系统,采用了基于时间.事件和密钥三变量而产 ...

  9. Google Authenticator(谷歌身份验证器)

    <!DOCTYPE html>Google Authenticator(谷歌身份验证器) ] Google Authenticator(谷歌身份验证器) Google Authentica ...

随机推荐

  1. Java异常处理的10个最佳实践

    本文作者: ImportNew - 挖坑的张师傅 未经许可,禁止转载! 异常处理在编写健壮的 Java 应用中扮演着非常重要的角色.异常处理并不是功能性需求,它需要优雅地处理任何错误情况,比如资源不可 ...

  2. @Html.AntiForgeryToken() 源码分析,表单防伪码的生成

    源码来自MVC4@Html.AntiForgeryToken() 源码分析 public MvcHtmlString AntiForgeryToken() { return new MvcHtmlSt ...

  3. Python-OpenCV中的图像模糊

    目录 1. 高斯模糊:cv2.GaussianBlur()   主要记录Python-OpenCV中的图像模糊操作: 1. 高斯模糊:cv2.GaussianBlur() def GaussianBl ...

  4. Unable to round-trip http request to upstream: EOF问题

    Unable to round-trip http request to upstream: EOF, 今天我用的phpstudy环境中的网站页面忽然打不开了,报错“Unable to round-t ...

  5. QuotaExceededError: The quota has been exceeded. localStorage缓存超出限制

    今天在项目中遇到了一个问题,localStorage存储超出限制.报错信息如标题.这个是因为最近做了一波优化,把导航栏和一些用户信息本地化存储,都放在localStorage里,也不是每个用户会出现这 ...

  6. 什么时候要重写equals

    什么时候要重写equals 当对象需要根据值去比较它们是否相等时,需要我们重写equals,而它的hashCode也同时需要被重要,一般来说就是对类里所有成员变更求hashCode. 没有重写equa ...

  7. Ubuntu下nagios安装(来源官网)

    Ubuntu下nagios安装(来源官网) https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/toc.html h ...

  8. Java定时任务的几种实现方式

    java Timer比较具体的实现实例 https://www.cnblogs.com/0201zcr/p/4703061.html 转载大神 的 https://blog.csdn.net/kegu ...

  9. jvm 锁Lock

    自旋锁 线程想要获得一个对象的锁,如果没有得到,会继承占用CPU尝试获取锁, 线程不进入阻塞状态,仍然在Running 锁消除 public void lockTest() { String aa = ...

  10. bitnami-redmine Apache服务启动不起来

    方法一: 通过 netstat -a -o 查看端口占用情况,关闭调用相关端口的进程.  c:\> netstat -a -o  Active Connections  Proto  Local ...