43.10. Google Authenticator - Android Apps on Google Play

 
#### ssh 二次认证

1) 安装依赖环境
yum install gcc wget pam-devel libpng-devel libtool

2) 安装二维码工具
yum install -y  qrencode

3) 安装 google_authenticator (EPEL repo)
yum install google-authenticator -y

4) setup
<1> Using command line switch to the user you want to setup Google 2-step verification for
[root@test23 src]# su root
<2>  Run the Google Authenticator script and answer yes (y) to all questions:
[root@test23 src]# google-authenticator
<3> 执行 google-authenticator 命令 会生成一张二维码 ,手机下载   google authenticator app  扫描上面的二维码(或者手动输入),这样就能实现 基于时间的 口令同步.同时在用户的家目录下 下面5个是万能钥匙   用一次少一个 .
<4> 设置 ssh 登陆认证方式,Edit the file /etc/pam.d/sshd,and add this line towards the top of the file:
# google authenticator
auth required pam_google_authenticator.so
<5>Next, edit the file /etc/ssh/sshd_config ,and change the ChallengeResponseAuthentication value to yes so it looks something like:
# google authenticator
ChallengeResponseAuthentication yes
<6> 重启 sshd 服务

#### 普通用户su到root用户二次认证

[root@test23 redhat]# cat /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
# google authenticator
auth required pam_google_authenticator.so
auth            include        system-auth
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so

#### 普通用户su到root用户不需要输入系统密码认证

[root@test23 redhat]# cat /etc/pam.d/su
#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth           required        pam_wheel.so use_uid
# google authenticator
auth            required        pam_google_authenticator.so
auth            [success=ignore default=1] pam_succeed_if.so user = root
auth            sufficient      pam_succeed_if.so use_uid user = redhat
auth            include         system-auth
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         optional        pam_xauth.so

其中:
auth            [success=ignore default=1] pam_succeed_if.so user = root
auth            sufficient      pam_succeed_if.so use_uid user = redhat
第一行的意思是 要 su 到哪个用户不需要输入密码
第二行的意思是 要从哪个用户 su 到一行时候才不要密码
由于 auth            required        pam_google_authenticator.so 这一行在前面,所有 本列中从 redhat su 到 root ,不需要输入 root 的系统密码, 但是需要输入 google 的动态口令.

如果说想指定和多用户 su 到 root 都不需要 root 密码,只需输入动态口令,有两种方式:

1)  把上面的两行改成如下
auth            [success=ignore default=1] pam_succeed_if.so user = root
auth            sufficient      pam_succeed_if.so use_uid user ingroup allowedpeople

意思是把 需要的普通用户都加入一个 allowedpeople 用户组里, 对该用户组授权!

2) 见下面是用 普通用户 sudo 到 root 用户不需要输入系统密码认证

#### 普通用户 sudo 到 root 用户不需要输入系统密码认证

1) 切换到普通用户(redhat) 执行google-authenticator

2) 此普通用户(redhat)在 sudo 的配置文件为

redhat ALL=(ALL) /bin/su - root

3) 修改 sudo 的pam 文件如下
[root@test23 pam.d]# cat /etc/pam.d/sudo
#%PAM-1.0
# google authenticator
#auth       required      pam_radius_auth.so
auth    required pam_google_authenticator.so
#auth       include      system-auth
account    include      system-auth
password   include      system-auth
session    optional     pam_keyinit.so revoke
session    required     pam_limits.so

4) 普通用户通过 google 口令 sudo  到 root 用户
[redhat@test23 ~]$ sudo su - root
Verification code:
[root@test23 ~]#

另外一种方式 见 Radius
  
 

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

时间: 2024-07-29 11:23:23

43.10. Google Authenticator - Android Apps on Google Play的相关文章

用 Google Authenticator 加强 VPS 及 WordPress 甚至桌面电脑的安全性

传统地用 SSH 登录 VPS 的时候,靠的只是一串字符密码,如果密码被泄露.被猜解.被暴力枚举成功,那么 VPS 就完全暴露在坏人手中了.安全意识高一些的用户会使用公私钥代替字符来登录,但是这样的缺点是如果在陌生的电脑上想要临时登录一下,由于没有私钥,也就没办法了.传统地登录 WordPress 的时候,更是只有一个密码,如果被泄露.猜解.暴力枚举,辛辛苦苦经营的博客就完蛋了. 本文介绍如何通过 Google Authenticator 构建"物理屏障",最大限度地阻断来自网络的密码

Android中新引进的Google Authenticator验证系统工作原理浅析

为了改进Android的安全问题,Google在Android系统中引入了谷歌验证应用(Google Authenticator)来保证账号的安全.谷歌验证应用的使用方法是:用户安装手机客户端,生成临时身份验证码,提交到服务器验证身份,类似的验证系统还有Authy.Robbie在其GitHub页面发布了自己用Go语言实现的版本,并撰写了一篇博文来解释其工作原理. 通常来讲,身份验证系统都实现了基于时间的一次性密码算法,即著名的TOTP(Time-Based One-Time Password).

使用Google Authenticator实现WordPress多步验证登录

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断 淘宝客 云主机 技术大厅 大家都知道WordPress拥有着上千万用户,相对而言是比较安全的.但常常某些站长使用了admin.123456.888888之类的密码类型使网站极易被攻破.因为WP的后台并没有设置验证码限制登录,所以在前几个月里某名黑客就使用穷举的方式破获了数百个用户名为admin的WordPress用户密码,此类问题不容小视.今天就来和大家一起探讨如何使

CentOS下Google Authenticator配置SSH登录动态验证码配置

说明: 1.一般ssh登录服务器,只需要输入账号和密码. 2.本教程的目的:在账号和密码之间再增加一个验证码,只有输入正确的验证码之后,再输入密码才能登录.这样就增强了ssh登录的安全性. 3.账号.验证码.密码三者缺一个都不能登录,即使账号和密码正确,验证码错误,同样登录失败. 4.验证码:是动态验证码,并且是通过手机客户端自动获取(默认每隔30秒失效一次). 5.最终目的:远程ssh登录一台服务器,需要正确的账号.密码.及一个可以获取到动态验证码的手机(目前支持Android和ios手机系统

Android之后,Google找的未来是给一切加上人工智能

Google 一年一度的开发者大会开到第九届,规模也是前所未有的大,从此前的室内会展中心搬到了可以容纳超过两万人的海岸圆形剧场(Shoreline Amitheater). 会场周边还设置了 10 个户外展台和产品体验区,活动将连续举办 3 天. 今年的 Google I/O 把主会场搬到了室外.图片来自视觉中国. 但在这样的盛大活动里,Android 已经不是主角.持续两小时的开场演讲,新系统 Android N 只有 17 分钟,还不如新聊天应用 Allo 的时间长. 早在大会召开前两个月,

欧盟调查出炉,Google在Android上的授权有垄断之虞、阻碍创新

Android 是 Google旗下免费.开源的操作系统平台,但 Google 却因这"免费"的平台,被欧盟指控违反反托拉斯法,伤害使用者.扼杀竞争者.限制创新.何以欧盟对 Google Android 以如此严重的指控? 欧盟调查 Android 违反反拖拉斯法的文件出炉,欧盟在 20 日发布新闻稿,指欧盟执委会竞争政策总署对于 Google 在 Android 操作系统以及应用程序的授权条款有所异议,主要是 Google 滥用自己的领先地位,对想要获得 Android 授权的手机制

Google开放Android电子书店

我们猜到了结果,但是现在只实现了一半.前几天我们曾报道称Google的Android电子市场网页版中加入了一些二级目录,分别是 market.android.com/books.market.android.com/music.market.android.com /movies,这也预示着Google正在测试电子书.音乐和电影这三项内容服务,现在电子书页面已经开放.Android电子书市场是为了配合3.0蜂窝系统http://www.aliyun.com/zixun/aggregation/1

申请Google Map Android API Key

要想使用Google的Map服务编写应用,无论是Google Map API和Google Map Android API都需要申请Key.Google Map API中的Key的申请这里就不介绍了,主要介绍Google Map Android API的Key,它的申请步骤如下:• 找到或创建keystore证书文件:• 生成MD5认证指纹:• 生成Google Map API Key.1.找到或创建keystore证书文件我们在本书的第3章的应用程序的打包.安装和卸载部分已经介绍了,本章就不再

Google手机Android操作系统面试题

    Google 手机 Android操作系统面试题      1﹑Android 手机操作系统的四层架构?        架构框架以此从上到下:       1.Applications   (应用程序(应用层)):       Android 会同一系列核心应用程序包一起发布,该应用程序包包括 email 客户端,SMS 短消息程序,日历,地图,浏览器,联系人管理程序等.所有的应用程序都是使用 JAVA 语 言编写的.       2.Application FrameWork    (