1. 下载 Google的身份验证模块
  1. 安装相关依赖包

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

  1. 解压缩并编译安装

# tar xvf libpam-google-authenticator-1.0-source.tar.bz2

# cd libpam-google-authenticator-1.0

# make

# make install

  1. 添加验证机制

比如,我们想为账户:lw 增加一层额外的验证机制,则先通过google-authenticator生成密钥:

[lw@localhost ~]$ google-authenticator

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

首先会提示你,是否要基于时间生成令牌,选择Y,然后它会生成密钥,以及紧急状态使用的验证码(有5个,谨当无法获取验证码时使用,注意这些紧急验证码用一次就少一个的哟,所以这几个紧急验证码一定要保存好,关键时刻要派上大用场的),详细信息如下:

https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/jss@localhost.localdomain%3Fsecret%3D3V7K2ONO55DE56SD

Your new secret key is: 3V7K2ONO55DE56SD

Your verification code is 424380

Your emergency scratch codes are:

96307775

87311306

56915688

84694809

27875014

然后会提示你是否要更新验证文件,肯定更新啊:

Do you want me to update your "/home/jss/.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

默认情况下,令牌只在30秒内有效,由于客户端和服务器时间不完全一致的因素,可以将时间窗口加大到最长4分钟,是否要这么做:

By default, tokens are good for 30 seconds and 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. If you experience problems with poor

time synchronization, you can increase the window from its default

size of 1:30min to about 4min. Do you want to do so (y/n) y

是否限制尝试次数,每30秒只能尝试最多3次:

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

密钥生成好之后,下面修改PAM中关于ssh的配置,编辑/etc/pam.d/sshd文件:

# vim /etc/pam.d/sshd

第一行增加:

auth    required        pam_google_authenticator.so

接下来再修改ssh的配置文件,编辑/etc/ssh/sshd_config文件:

# vim /etc/ssh/sshd_config

将ChallengeResponseAuthentication no修改为ChallengeResponseAuthentication yes

然后重新启动ssh服务:

当再次使用lw用户ssh登录服务器的时候,就会提示输入验证码:

[lw@linuxtl ~]$ ssh -p52113 10.51.76.191

Verification code:

  1. 手机添加验证码客户端

在手机上安装一款名叫:Google身份验证器的应用(或者有一款叫做洋葱的软件)。在打开的应用界面中新增帐户,然后会出现两个选择:扫描条形码(二维码),或者选择输出提供的密钥,任选其一即可。

这两项信息从哪里来呢?前面执行google-authenticator命令后首先输出的信息,那个HTTP的网址,打开你就会发现,原来它是个图片二维码,扫描即可。若网址打不开也没关系,选择密钥就OK了。

帐户添加完成后,你应该就能在手机上看到它生成的验证码了,先输入验证码,然后再输入密码,只有验证码和密码都输入正确,才能正常登录。

  1. 使用crt等工具连接服务器

1、如果命使用SecureCRT客户端登录时,需要在 连接——属性——连接——ssh2——"鉴权/authenicaion" 中将 "键盘交互/keyboard Interactive" 调到第一位。不然连接会出错。

2、以上安全配置对于ssh密钥认证方式进行的登录无效——即在pam配置中增加上面的配置后,通过密钥认证时不会要求输入验证码 。

谷歌身份验证器加强Linux帐户安全的更多相关文章

  1. 通过Google身份验证器加强Linux帐户安全

    下载Google的身份验证模块: # wget https://google-authenticator.googlecode.com/files/libpam-google-authenticato ...

  2. Google Authenticator(谷歌身份验证器)

    <!DOCTYPE html>Google Authenticator(谷歌身份验证器) ] Google Authenticator(谷歌身份验证器) Google Authentica ...

  3. Google Authenticator(谷歌身份验证器)C#版

    摘要:Google Authenticator(谷歌身份验证器),是谷歌公司推出的一款动态令牌工具,解决账户使用时遭到的一些不安全的操作进行的"二次验证",认证器基于RFC文档中的 ...

  4. 七牛云如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器?

    一般情况下,点账户名——账户设置——安全设置,即可开通两步验证 具体步骤见链接  七牛云如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器?   二次验证码小程序(官网)对比谷歌身份验证器APP ...

  5. humlbe bundle如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器?

    一般点账户名——设置——安全设置中开通虚拟MFA两步验证 具体步骤见链接 humlbe bundle如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器? 二次验证码小程序于谷歌身份验证器APP的 ...

  6. R星游戏如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器?

    一般点账户名——设置——安全设置中开通虚拟MFA两步验证 具体步骤见链接 R星游戏如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器? 二次验证码小程序于谷歌身份验证器APP的优势 1.无需下载 ...

  7. WBF交易所如何使用二次验证码/谷歌身份验证器

    一般点账户名——设置——安全设置中开通虚拟MFA两步验证 具体步骤见链接  WBF交易所如何使用二次验证码/谷歌身份验证器 二次验证码小程序于谷歌身份验证器APP的优势 1.无需下载app 2.验证码 ...

  8. 关于虎信如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器?

    一般点账户名——设置——安全设置中开通虚拟MFA两步验证 具体步骤见链接 虎信如何绑定二次验证码_虚拟MFA_两步验证_谷歌身份验证器? 二次验证码小程序于谷歌身份验证器APP的优势 1.无需下载ap ...

  9. paypal支付平台如何使用二次验证码_虚拟MFA_两步验证_谷歌身份验证器?

    一般点账户名——设置——安全设置中开通虚拟MFA两步验证 具体步骤见链接 paypal支付平台如何使用二次验证码_虚拟MFA_两步验证_谷歌身份验证器? 二次验证码小程序于谷歌身份验证器APP的优势 ...

随机推荐

  1. java语言实现堆排序

    package secondChapter; import java.util.Random; public class HeapSort { private static int AHeapSize ...

  2. VS2013的一些常用快捷键

    1.回到上一个光标位置/前进到下一个光标位置 1)回到上一个光标位置:使用组合键“Ctrl + -”: 2)前进到下一个光标位置:“Ctrl + Shift + - ”. 2.复制/剪切/删除整行代码 ...

  3. 12. Binary Tree Postorder Traversal && Binary Tree Preorder Traversal

    详见:剑指 Offer 题目汇总索引:第6题 Binary Tree Postorder Traversal            Given a binary tree, return the po ...

  4. 构造方法Constructor

    构造函数的名称与类名相同,没有返回值类型,主要用于在创建对象的时候进行一些初始化操作,如一个类中没有构造方法,java会默认给一个无参的构造方法

  5. oracle10g配置小记

    因对接HIS系统,对方提供了视图.故此我拿起多年不用的ORACLE. 初始安装一切正常,然后打开Net Configuration Assistant配置监听程序. 接着配置 本地NET服务名配置 打 ...

  6. IOS畅销榜

    20W 在80-100  30W 在50左右  50W 在30左右  100W在20左右 N-1日的 收入  对N日还有权重的影响

  7. php接口post提交方法 (改良版)

    $postData = "reqType=2&caller=15088719619&called=15068722845"; $result = send_post ...

  8. leetcode 160

    160. Intersection of Two Linked Lists Write a program to find the node at which the intersection of ...

  9. 41. 这张表lbdeveloplog可以查看各个对象的提交情况,包括是哪个IP提交的

    lbdeveloplog 这张表lbdeveloplog可以查看各个对象的提交情况,包括是哪个IP提交的

  10. 第五百八十二天 how can I 坚持

    好吧,是我错了,昨天,做好自己就行了,别人怎么样是别人的事,永远保持一颗单纯向上的心. 时间过得真快,明天又周六了.. 睡觉.