1,安装依赖

yum install python-pip -y
pip install docutils
yum install gcc python-devel subversion pam pam-devel -y

2,下载git包

cd /home/lanny/tools/
unzip google-authenticator-master.zip
cd google-authenticator-master
cd libpam/
./bootstrap.sh
./configure
make
make install

3,配置文件

ll /lib64/security
google-authenticator,则复制到/usr/local/bin
ll /usr/local/bin/google-authenticator #pl2pm /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so openvpn

4,为root用户生成google验证码

[root@vpnserver ~]# 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@vpnserver%3Fsecret%3D7ZSEKQI6W7GJXDDBEBJJINHY3Q%26issuer%3Dvpnserver
Your new secret key is: 7ZSEKQI6W7GJXDDBEBJJINHY3Q
Your verification code is 496552
Your emergency scratch codes are:
70752164
63976717
73442435
67261408
95454901 修改pam.d
[root@vpnserver pam.d]# cat /etc/pam.d/sshd
#%PAM-1.0
auth required pam_google_authenticator.so <---追加
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth =================================================
修改ssh配置: vim /etc/ssh/sshd_config
83 ChallengeResponseAuthentication yes 测试:手机下载google身份验证器,登陆(root用户哦) ====================================================
为jss生成:
jss 密码 sss
===============
[jss@vpnserver ~]$ 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/jss@vpnserver%3Fsecret%3DLNS6P7ONML6LCOFPKXW4OFWYS4%26issuer%3Dvpnserver
Your new secret key is: LNS6P7ONML6LCOFPKXW4OFWYS4
Your verification code is 755883
Your emergency scratch codes are:
41886633
49746589
44517353
13151010
41992403
=========================
注意:
1.如果无法登陆
cp /usr/local/lib/security/pam_google_authenticator.so /lib64/security/
2,
Google身份验证器每隔三十秒就会变的。这就实现了动态验证码的功能。
3,5个紧急验证码,用一个少一个. 4,
默认情况下,令牌只在30秒内有效,由于客户端和服务器时间不完全一致的因素,可以将时间窗口加大到最长4分钟
5,是否限制尝试次数,每30秒只能尝试最多3次:
6, google-authenticator针对单用户

参考

回滚为初始ssh状态

[root@vpnserver ~]# cat /etc/pam.d/ssh
cat: /etc/pam.d/ssh: No such file or directory
[root@vpnserver ~]# cat /etc/pam.d/sshd
#%PAM-1.0
#auth required pam_google_authenticator.so # 注释掉即可

[svc]ssh+gg二步认证的更多相关文章

  1. [svc]centos6上部署openvpn+gg二步认证

    最近又发现个新的vpn: wireguard 为了满足员工在家办公的需求.需要 openvpn+gg方案 在centos6上部署openvpn 参考 1.安装前准备 wget -O /etc/yum. ...

  2. TOTP算法实现二步验证

    概念 TOTP算法(Time-based One-time Password algorithm)是一种从共享密钥和当前时间计算一次性密码的算法. 它已被采纳为Internet工程任务组标准RFC 6 ...

  3. SSH的通讯和认证

    SSH的通讯和认证 转自:http://blog.sina.com.cn/s/blog_4e9440910100zxk0.html 之前一直对SSH的认证模棱两可,今天对SSH的通讯,认证和配置有了进 ...

  4. 给 SSH 启用二次身份验证

    转载自:https://mp.weixin.qq.com/s/ssuhFbfaHxxzGmLg6Y2MjA 目前来说,二次验证(这里就不做过多解释了)是比较常用的安全手段,通过设置二次验证(谷歌或其他 ...

  5. HTTP协议 (二) 基本认证

    HTTP协议 (二) 基本认证 http协议是无状态的, 浏览器和web服务器之间可以通过cookie来身份识别. 桌面应用程序(比如新浪桌面客户端, skydrive客户端)跟Web服务器之间是如何 ...

  6. Coding 两步认证技术介绍

    什么是两步认证 在介绍两步认证之前,首先来看下目前主流的几种认证方式. 上图中的认证方式大体上可以分为三大类 1.You know : 比如密码,这种只有我们知道的 2.You are : 比如指纹, ...

  7. ssh登录二次验证,让服务器更安全。

    码云地址 sshdTwoVerification 介绍 ssh登录二次验证 问题:现在很多人的Linux服务器可能会被攻击,只校验一次后台用户名密码登录变得不再保险. 当然大家首先要做的是修改ssh服 ...

  8. JHipster生成微服务架构的应用栈(二)- 认证微服务示例

    本系列文章演示如何用JHipster生成一个微服务架构风格的应用栈. 环境需求:安装好JHipster开发环境的CentOS 7.4(参考这里) 应用栈名称:appstack 认证微服务: uaa 业 ...

  9. java实现谷歌二步验证 (Google Authenticator)

    准备: 一个谷歌二步验证APP,  我用的是ios 身份宝 资料: 1.Google Authenticator 原理及Java实现   //主要参考 https://blog.csdn.net/li ...

随机推荐

  1. 基于python2【重要】怎么自行搭建简单的web服务器

    基本流程:1.需要的支持     1)python本身有SimpleHTTPServer     2)ForkStaticServer.py支持,该文件放在python7目录下     3)将希望共享 ...

  2. 编程填空:左边i位取反

    总时间限制: 1000ms 内存限制: 1024kB描述写出函数中缺失的部分,使得函数返回值为一个整数,该整数的左边i位是n的左边i位取反,其余位和n相同请使用[一行代码]补全bitManipulat ...

  3. 在CLion项目中指定不同版本的链接库

    在项目中, 需要使用到libevent-2.1.x, 但是Ubuntu16.04自带的libevent版本为2.0.5, 需要另外编译安装新版的libevent, 安装过程很简单 -stable.ta ...

  4. Qt5中创建临时的后台线程。

    有个需求就是,GUI图形界面在上传文件到服务器的时候,需要用zip命令行打包,因为文件很多的时候,zip命令打包需要计算很长时间,所以把这样计算量大的任务分离到后台线程比较合适,然后任务完成,以信号槽 ...

  5. js实现放大缩小页面

    <script type="text/JavaScript"> var size = 1.0; function zoomout() { size = size + 0 ...

  6. ios发布

    https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Gu ...

  7. Delphi消息推送

    移动端的消息推送大家都体验过,智能手机上一大堆广告等各种消息会不时从消息栏中弹出来骚扰你. PC程序中我们有时也会用到消息推送,比如通知之类.通常我们使用的方法可能更多地使用Socket之类来处理,有 ...

  8. mysql--SQL编程(关于mysql中的日期,关于重叠) 学习笔记2.2

    1.日期中的重叠问题建表sessions: CREATE TABLE `sessions` ( `id` ) NOT NULL AUTO_INCREMENT, `app` ) NOT NULL, `u ...

  9. mysql my.cnf 配置建议

    mysql的配置文件是/etc/my.cnf,通过修改它来配置mysql. /etc/my.cnf来自以下文件: 如果你的内存≤64M,则复制/usr/local/share/mysql/my-sma ...

  10. 树莓派进阶之路 (020) - 基于24位AD转换模块HX711的重量称量实验

    参考文档:http://www.geek-workshop.com/thread-2315-1-1.html 参考文档:https://wenku.baidu.com/view/e5d5e4e2652 ...