#### 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 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

43.10. Google Authenticator - Android Apps on Google Play相关推荐

  1. python 双因子认证 Google Authenticator令牌代码实现

    代码封装实现: 逻辑包括但不限于:生成二维码.生成密钥.校验动态口令 # -*- coding: utf-8 -*- import base64 from io import BytesIO impo ...

  2. 如何将您的Google Authenticator凭证移至新的Android手机或平板电脑

    Most of the app data on your Android is probably synced online will automatically sync to a new phon ...

  3. Android Studio Error: Google Play requires that apps target API level 30 or higher.

    Android Studio Error: Google Play requires that apps target API level 30 or higher. flyfish 在build.g ...

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

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

  5. Google Authenticator:将其与您自己的Java身份验证服务器配合使用

    用于移动设备的Google Authenticator应用程序是一个非常方便的应用程序,它实现了TOTP算法(在RFC 6238中指定). 使用Google Authenticator,您可以生成时间 ...

  6. 如何使用Google Authenticator在ASP.NET Core中设置两因素身份验证

    介绍 (Introduction) In this article, we are going to learn how to perform two-factor authentication in ...

  7. 我为什么反对 Google 拍卖 Android 搜索引擎选项?

    Google 长久的搜索"垄断",让开发者们别无他选? 作者 | Christian 译者 | 胡雪蕊,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: ...

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

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

  9. 【译】SafetyNet:Google对Android的篡改检测 (SafetyNet: Google's tamper detection - Part 1 )

    什么是SafetyNet Android Pay应用程序已于几天前发布.一些使用植根设备的人发现它拒绝工作.这是因为它使用了新的Google Play服务功能:SafetyNet证明. SafetyN ...

最新文章

  1. pytorch之Tensor与Variable的区别
  2. 计算机专业课程设计报告c语言,计算机程序设计(C语言)课程设计报告.doc
  3. 实变函数与泛函分析课本pdf_实变函数与泛函分析
  4. u盘模式 linux hi3518,嵌入式 RT3070_STA驱动移植到hi3518c平台小结
  5. 【LeetCode】剑指 Offer 43. 1~n 整数中 1 出现的次数
  6. Android开发笔记(一百七十七)借助FileProvider安装应用
  7. 集群oracle实例扩sga,oracle管理基础知识
  8. ssm水电费管理系统java
  9. amd linux raid,RAID的详解
  10. 分销与供应链电子元器件采购需要掌握哪些基础知识?
  11. 7.Python3标准库--文件系统
  12. Ubuntu 的软件管理工具
  13. 为师生负重前行:记校园防疫中的故事
  14. 2007年互联网发展趋势预测:RSS将成为主流
  15. html点击弹出登录注册表单提交代码
  16. 前端程序猿常用网站总结
  17. TraceId 搭配 ELK,碉堡了
  18. 一个Ajax数字排列游戏
  19. 免签支付是什么意思?
  20. 微信小程序 手写签名_微信小程序实现手写签字

热门文章

  1. 【微软资源站】MSDN
  2. 怎么清理android的其他文件夹,手机储存里的其他是什么以及应该怎样删除
  3. Ajax简单实现注册用户名校验
  4. 命名实体识别的一点经验
  5. 视频网站大幅提价无异于“逆水行舟”
  6. java按照模板导出word 文档
  7. 风雨砥砺,岁月如歌——Ts之箭头函数
  8. 【PyTorch深度学习项目实战100例目录】项目详解 + 数据集 + 完整源码
  9. 成都web前端开发工程师
  10. java毕业生设计忆居民宿管理计算机源码+系统+mysql+调试部署+lw