CentOS 使用 Google Authenticator 登录验证

手机上安装Google身份验证器

安装地址:http://www.wandoujia.com/apps/com.google.android.apps.authenticator2

注意:机器上一定要关闭selinux

1、安装依赖:

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

2、开启EPEL源

yum –enablerepo=epel

3、或者直接安装EPEL源RPM包

# CentOS 6

rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/epel-release-latest-6.noarch.rpm

# CentOS 7

rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/epel-release-latest-7.noarch.rpm

4、安装Qrencode,谷歌身份验证器需要调用该程序生成二维码并显示

yum install -y qrencode

5、安装谷歌身份验证器

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

编译并安装

./bootstrap.sh
./configure --prefix=/usr/local/google-authenticator
make && make install

复制google 身份验证器pam模块到系统下

cp /usr/local/google-authenticator/lib/security/pam_google_authenticator.so /lib64/security/

6、配置/etc/pam.d/sshd

auth       include      password-auth

这一行上面添加下面这行内容

auth       required     pam_google_authenticator.so

注意顺序:谷歌认证要在password-auth上面

[[email protected] ~]# cat /etc/pam.d/sshd

#%PAM-1.0
auth       required     pam_sepermit.so
auth       required     pam_google_authenticator.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

7、修改SSH服务配置/etc/ssh/sshd_config

将ChallengeResponseAuthentication no改成yes,即

ChallengeResponseAuthentication yes

8、启用 Google Authenticator

./google-authenticator

Do you want authentication tokens to be time-based (y/n) y

# 是否开启基于时间的认证,Y, 测试下来,如果选N,则手机上的验证码不会自动更新,使用一次后就算手动更新了验证码也无法登录。

# 接下来会生成二维码,手机端扫描即可添加安全密钥

后面一路都是选择y,就可以了

注意保存好上面的5个emergency scratch codes,如果手机上的验证码不通过,可以使用上面的这个验证码,每次使用后就失效了。

linux登录客户端的设置

参考文档:

https://shenyu.me/2016/09/05/centos-google-authenticator.html

https://www.sulabs.net/?p=802

原文地址:http://blog.51cto.com/zengestudy/2112706

时间: 2024-07-30 21:40:08

CentOS 使用 Google Authenticator 登录验证的相关文章

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

准备: 一个谷歌二步验证APP,  我用的是ios 身份宝 资料: 1.Google Authenticator 原理及Java实现   //主要参考 https://blog.csdn.net/lizhengjava/article/details/76947962# 2.谷歌验证 (Google Authenticator) 的实现原理是什么? https://www.zhihu.com/question/20462696 3.谷歌验证,又称两步验证, https://www.360shou

Google authenticator 登陆 Wordpress和 Gmail账号

这段时间在学习aws,发现可以通过配置google authenticator来强化登陆的安全性.心想能不能把Google authenticator用在其他地方呢?意外的发现wordpess和Gmail Account也是支持的. WordPress配置很简单,首先安装Plugin,激活 然后在管理员的Profile下面,生成二维码 iPhone上安装对应的软件,(左下角白***标),扫描二维码,即可绑定 保存Wordpress的设置,重新进入登录界面,发现多了个验证码的选项 下面我的截图里面

使用Google Authenticator给ssh进行登录验证

普通情况下的服务器登录,是"服务器+密码"这种直白的验证方式,但是这种方式太过简单,一旦密码泄露,服务器就有危险,于是为了安全我们就要在登录上再加一把锁,那就是使用Google Authenticator(谷歌身份验证器)这个工具,在登录的时候进行一次验证,只有"验证通过了"+"密码正确"才能登陆服务器. 安装前准备: 1)关闭Selinux :#setenforce 0 2)安装依赖:#yum -y install gcc make pam-d

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

一般来说,使用ssh远程登录服务器,只需要输入账号和密码,显然这种方式不是很安全.为了安全着想,可以使用GoogleAuthenticator(谷歌身份验证器),以便在账号和密码之间再增加一个验证码,只有输入正确的验证码之后,再输入密码才能登录.这样就增强了ssh登录的安全性.账号.验证码.密码三者缺一个都不能登录,即使账号和密码正确,验证码错误,同样登录失败.其中,验证码是动态验证码,并且是通过手机客户端自动获取(默认每隔30秒失效一次) Google Authenticator开源版主页 h

谷歌验证 (Google Authenticator) 的实现原理是什么?

著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:徐小花链接:http://www.zhihu.com/question/20462696/answer/18731073来源:知乎 开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码. 实现Google Authenticator功能需要服务器端和客户端的支持.服务器端负责密钥的生成.验证一次性密码是否正确.客户端记录密钥后生成一次性密码.

Google Authenticator SSH双重验证技术

    Technology - Site OPS Google Authenticator SSH双重验证技术 管理手册 目  录 第1章引言... 1 1.1 目的... 1 1.2 说明... 1 第2章 SSH 双重验证实现... 2 2.1 基础工作... 2 2.2 配置工作... 2 第3章手机客户端配置... 4 第4章 SSH 登录验证... 6 4.1XSHELL 登录验证... 6 4.2 跳板机登录... 7 4.3 总结... 8 第1章 引言 1.1 目的 SSH 安

SSH使用Google Authenticator二次验证

基本的原理如上图: 客户端在输入code码之后,才可以输入服务器的密码,进行账户验证,方可进入服务器. 实现方式如下: 1. 安装所需组件 # yum -y install mercurial pam-devel 2.  安装qrencode,在Linux上,有一个名为 QrenCode 的命令行工具可以很容易帮我们生成二维码,google authenticator命令行生成二维码就是调用它. # wgethttp://fukuchi.org/works/qrencode/qrencode-3

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

1.介绍 双因素认证:双因素身份认证就是通过你所知道再加上你所能拥有的这二个要素组合到一起才能发挥作用的身份认证系统.双因素认证是一种采用时间同步技术的系统,采用了基于时间.事件和密钥三变量而产生的一次性密码来代替传统的静态密码.每个动态密码卡都有一个唯一的密钥,该密钥同时存放在服务器端,每次认证时动态密码卡与服务器分别根据同样的密钥,同样的随机参数(时间.事件)和同样的算法计算了认证的动态密码,从而确保密码的一致性,从而实现了用户的认证.因每次认证时的随机参数不同,所以每次产生的动态密码也不同

Google authenticator 谷歌身份验证,实现动态口令

google authenticator php 服务端 使用PHP类 require_once '../PHPGangsta/GoogleAuthenticator.php'; $ga = new PHPGangsta_GoogleAuthenticator(); //创建一个新的"安全密匙SecretKey" //把本次的"安全密匙SecretKey" 入库,和账户关系绑定,客户端也是绑定这同一个"安全密匙SecretKey" $secret