阿里云相关链接

https://www.aliyun.com/product/ecs?source=5176.11533457&userCode=kv73ipbs&type=copy

1、环境

系统:centos6.5 x86_64

[root@uu ~]# uname -a

Linux uu 2.6.32-642.el6.x86_64 #1 SMP Wed Apr 13 00:51:26 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

要求:

时间同步

关闭SELinux

2、安装

升级git

1.7.1版本过低,现在github不支持1.7.1的git 客户端的下载了,只有从网上下载高一点的版本,并安装。

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y
yum install gcc perl-ExtUtils-MakeMaker -y
yum remove git -y
yum update -y nss curl libcurl cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz
wget https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz --no-check-certificate
tar xzf git-2.1..tar.gz
cd git-2.1.
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc #配置git不认证https
git config --global http.sslVerify false

3、安装Google auth

yum install -y git automake libtool pam-devel -y
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/

4、安装认证二维码

这一步可不做,没有图形二维码就手动输入程序给出的密钥。

yum install -y git qrencode

5、配置ssh服务

5.1、修改/etc/pam.d/sshd

在/etc/pam.d/sshd里添加下面这条【#放在auth       include      password-auth之前】

vim /etc/pam.d/sshd
auth required pam_google_authenticator.so no_increment_hotp

5.2、修改/etc/ssh/sshd_config

vim /etc/ssh/sshd_config
PasswordAuthentication yes
ChallengeResponseAuthentication yes
UsePAM yes
/etc/init.d/sshd restart

6、配置Google auth

google-authenticator

6.1、添加主机

有2种方式:

输入“y”后,会有一个二维码

1、用手机谷歌验证器扫描这个二维码即可添加主机。

2、手动输入二维码下面的密钥添加。

然后剩下的会出现5个问题,根据提示全部选“y”即可。

6.2、客户端

我的是华为手机,贴一下华为应用市场的链接

http://a.vmall.com/uowap/index.html#/detailApp/C63790

APP在应用市场搜索谷歌认证器。

可根据需要添加多个客户端。

7、登录

输入手机动态口令

输入登录用户的密码

8、说明

[root@uu ~]# google-authenticator

Do you want authentication tokens to be time-based (y/n) y
Warning: pasting the following URL into your browser exposes the OTP secret to Google:
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@uu%3Fsecret%3DJQPBXCQ5UJEARJDKW56QG7PX5M%26issuer%3Duu

Your new secret key is: JQPBXCQ5UJEARJDKW56QG7PX5M

Enter code from app (-1 to skip): 441989

Code confirmed

Your emergency scratch codes are:

15017326

13268423

41466235

66165819

90381302

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, a new token is generated every 30 seconds by the mobile app.

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. This allows for a

time skew of up to 30 seconds between authentication server and client. If you

experience problems with poor time synchronization, you can increase the window

from its default size of 3 permitted codes (one previous code, the current

code, the next code) to 17 permitted codes (the 8 previous codes, the current

code, and the 8 next codes). This will permit for a time skew of up to 4 minutes

between client and server.

Do you want to do so? (y/n) 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

上述共需回答5个y

  第1个:问你是否想做一个基于时间的令牌

  第2个:是否更新你的google认证文件,由于第一次设置,所以一定选y 

  第3个:是否禁止口令多用,这里选择y,禁止它,以防止中间人欺骗。

  第4个:默认情况,1个口令的有效期是30s,这里是为了防止主机时间和口令客户端时间不一致,设置的误差,可以选择y,也可选n,看要求严谨程度

  第5个:是否打开尝试次数限制,默认情况,30s内不得超过3次登陆测试,防止别人暴力破解。

并且上面这些设置将被存储在用户的〜/.google_authenticator文件中,emergency scratch codes 中的5个代码是紧急代码,务必牢记,这是在你的动态口令无法使用的情况下使用的,记住,用一个失效一个。后期可以登陆上去后,重新生成!!

centos6.5使用Google auth进行双因子认证的更多相关文章

  1. 强制禁用gitlab的双因子认证:Two-Factor Authentication

    (一)问题描述: 此博客解决如下问题:禁用gitlab的双因子认证 禁用前,如图(此时,你在gitlab中什么也干不了) (二)思路分析: 百度了很多方法,都不可靠(如不可靠的说明:https://s ...

  2. odoo12之应用:一、双因子验证(Two-factor authentication, 2FA)(HOTP,TOTP)附源码

    前言 双因子认证:双因子认证(2FA)是指结合密码以及实物(信用卡.SMS手机.令牌或指纹等生物标志)两种条件对用户进行认证的方法.--百度百科 跟我一样"老"的网瘾少年想必一定见 ...

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

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

  4. (诊断)解决GitHub使用双因子身份认证“Two-Factor Athentication”后无法git push 代码的“fatal: Authentication failed for ...”错误

    在GitHub上采取双因子身份认证后,在git push 的时候将会要求填写用户的用户名和密码,用户名就是用户在GitHub上申请的用户名,但是密码不是普通登录GitHub的密码. 一旦采取双因子身份 ...

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

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

  6. 双因子方差分析|adjusted R|强度|SSA|SSE|SST|

    应用统计学 方差分析的基本假设: 组间组平均与总平均的不同是由treatment引发的.单个值与组平均的不同是由组内error引发的. 如果没有处理误差SSA=SSE,所以右尾假设如果F>1则处 ...

  7. 业余草双因素认证(2FA)教程

    所谓认证(authentication)就是确认用户的身份,是网站登录必不可少的步骤.密码是最常见的认证方法,但是不安全,容易泄露和冒充.越来越多的地方,要求启用双因素认证(Two-factor au ...

  8. 双因素认证(2FA)教程

    所谓认证(authentication)就是确认用户的身份,是网站登录必不可少的步骤. 密码是最常见的认证方法,但是不安全,容易泄露和冒充. 越来越多的地方,要求启用 双因素认证(Two-factor ...

  9. linxu ssh 双端认证 不成功之authorized_keys

    linxu ssh 双端认证 不成功之authorized_keys liunx双端认证可以让我们更简便的在两台服务器之间传输文件,配置暂且不说,网上有大部分的文章可以搜索到,今天我要说的是在不成功的 ...

随机推荐

  1. vue eventBus 跳坑的办法

    前言(feihua): 最近闲来没事写了一个小的demo,在小的数据传输上没有必要去使用vuex,对于非父子组件的传值方法总结了一点心得体会供大家参考(如有太low,还请大神别喷俺) 先上官方文档: ...

  2. 论文翻译:BinaryNet: Training Deep Neural Networks with Weights and Activations Constrained to +1 or −1

    目录 摘要 引言 1.BinaryNet 符号函数 梯度计算和累积 通过离散化传播梯度 一些有用的成分 算法1 使用BinaryNet训练DNN 算法2 批量标准化转换(Ioffe和Szegedy,2 ...

  3. iis7.5做反向代理配置方法实例图文教程

    网络上好多开场的文章就说了好多的原理之类的这里我们直接开始配置.不过也要简单说下win下配置反向代理只有IIS7以上的版本才可以实现这个功能,在这里我们使用WINDOWS2008 R2来做为测试 20 ...

  4. *42. Trapping Rain Water 接雨水

    1. 原始题目 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水. 上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这 ...

  5. springboot动态多数据源

    参考文章:https://www.cnblogs.com/hehehaha/p/6147096.html 前言 目标是springboot工程支持多个MySQL数据源,在代码层面上,同一个SQL(Ma ...

  6. 基于用户的协同过滤电影推荐user-CF python

    协同过滤包括基于物品的协同过滤和基于用户的协同过滤,本文基于电影评分数据做基于用户的推荐 主要做三个部分:1.读取数据:2.构建用户与用户的相似度矩阵:3.进行推荐: 查看数据u.data 主要用到前 ...

  7. 初学python之路-day11

    一.函数的参数:实参与形参 # 参数介绍: # 函数为什么要有参数:因为内部的函数体需要外部的数据 # 怎么定义函数的参数:在定义函数阶段,函数名后面()中来定义函数的参数 # 怎么使用函数的参数:在 ...

  8. OverFeat学习

    [OverFeat Integrated Recognition,Localization and Detection using Convolutional Networks] Pierre Ser ...

  9. C# EntityFramework Code First 迁移

    如果使用的是 Code First 工作流,推荐使用 Code First 迁移改进应用程序的数据库架构. 迁移提供一组允许以下操作的工具: 创建可用于 EF 模型的初始数据库 生成迁移以跟踪对 EF ...

  10. Xamarin Layout属性(转)

    第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android: ...