通过Google身份验证器加强Linux帐户安全
下载Google的身份验证模块:
# wget https://google-authenticator.googlecode.com/files/libpam-google-authenticator-1.0-source.tar.bz2
解压缩并编译安装:
# tar xvf libpam-google-authenticator-1.0-source.tar.bz2
# cd libpam-google-authenticator-1.0
# make
# make install
而后,google的验证模块就会被复制到/lib64/security目录下,而用来生成密钥的可执行程序:google-authenticator,则复制到/usr/local/bin目录下,方便调用。
Tips:编译安装google-authenticator需要pam-devel依赖包,如果没有的话,请首先安装该依赖包。
比如,我们想为账户:liuke 增加一层额外的验证机制,则先通过google-authenticator生成密钥:
[liuke@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
Your emergency scratch codes are:
然后会提示你是否要更新验证文件,肯定更新啊:
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 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 :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 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服务:
当再次使用 liuke 用户以SSH方式登录时,就会提示输出验证码:
[root@localhost ~]# ssh liuke@192.168.33.126
Verification code:
那么,验证码从哪里来呢?在手机上安装一款名叫:Google身份验证器的应用。在打开的应用界面中新增帐户,然后会出现两个选择:扫描条形码(二维码),或者选择输出提供的密钥,任选其一即可。
这两项信息从哪里来呢?前面执行google-authenticator命令后首先输出的信息,那个HTTP的网址,打开你就会发现,原来它是个图片二维码,扫描即可。若网址打不开也没关系,选择密钥就OK了。
帐户添加完成后,你应该就能在手机上看到它生成的验证码了,先输入验证码,然后再输入密码,只有验证码和密码都输入正确,才能正常登录。
Password:
Last login: Tue Jan :: from 192.168.33.126
注意!!!输入验证码的时间最长只有30秒钟,超时之后该验证码就失效,需要到手机端获取新的验证码才行~
通过Google身份验证器加强Linux帐户安全的更多相关文章
- 谷歌身份验证器加强Linux帐户安全
下载 Google的身份验证模块 # wget https://google-authenticator.googlecode.com/files/libpam-google-authenticato ...
- linux上使用google身份验证器(简版)
系统:centos6.6 下载google身份验证包google-authenticator-master(其实只是一个.zip文件,在windwos下解压,然后传进linux) #cd /data/ ...
- 两步验证杀手锏:Java 接入 Google 身份验证器实战
两步验证 大家应该对两步验证都熟悉吧?如苹果有自带的两步验证策略,防止用户账号密码被盗而锁定手机进行敲诈,这种例子屡见不鲜,所以苹果都建议大家开启两步验证的. Google 的身份验证器一般也是用于登 ...
- 使用google身份验证器实现动态口令验证
最近有用户反应我们现有的短信+邮件验证,不安全及短信条数限制和邮件收验证码比较慢的问题,希望我们 也能做一个类似银行动态口令的验证方式.经过对可行性的分析及慎重考虑,可以实现一个这样的功能. 怎么实现 ...
- google 身份验证器
谷歌身份验证器原理 就是服务器与客户端算法相同
- Java使用google身份验证器实现动态口令验证
参考: 1)https://www.jb51.net/article/121243.htm 2)https://www.cnblogs.com/wuaili/p/9810661.html
- Google Authenticator(谷歌身份验证器)
<!DOCTYPE html>Google Authenticator(谷歌身份验证器) ] Google Authenticator(谷歌身份验证器) Google Authentica ...
- 计算机网络安全 —— C# 使用谷歌身份验证器(Google Authenticator)(五)
一.Google Authenticator 基本概念 Google Authenticator是谷歌推出的一款动态口令工具,旨在解决大家Google账户遭到恶意攻击的问题,在手机端生成动态口令后, ...
- win7 IIS7.0 【IIS 管理器无法验证此内置帐户是否有访问权】
异常信息: 服务器配置为将传递身份验证和内置帐户一起使用,以访问指定的物理路径.但是,IIS 管理器无法验证此内置帐户是否有访问权.请确保应用程序池标识具有该物理路径的读取访问权.如果此服务器加入到域 ...
随机推荐
- Java基础-接口.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,要求 方法 实现输出大写英文字母表的功能,printLowerca
#34.编写2个接口:InterfaceA和InterfaceB:在接口InterfaceA中有个方法void printCapitalLetter():在接口InterfaceB中有个方法void ...
- Android开发实践:编译VLC-for-android
最近在Android做流媒体相关的开发,一直想学习一下强大的VLC,正好趁此机会研究研究VLC-for-android的代码,看看优秀的开源音视频播放器是如何实现的.本文总结下在Linux平台下如何编 ...
- 实现CSS等分布局的4种方式
× 目录 [1]float [2]inline-block [3]table[4]flex 前面的话 等分布局是指子元素平均分配父元素宽度的布局方式,本文将介绍实现等分布局的4种方式 思路一: flo ...
- Mina、Netty、Twisted一起学(九):异步IO和回调函数
用过JavaScript或者jQuery的同学都知道,JavaScript特别是jQuery中存在大量的回调函数,例如Ajax.jQuery的动画等. $.get(url, function() { ...
- ASP.NET MVC图片管理(上传,预览与显示)
先看看效果(下面gif动画制作有点大,5.71MB): 题外话:上面选择图片来源于Insus.NET的新浪微博:http://weibo.com/104325017 也是昨晚(2015-07-03)I ...
- 让你心动的 HTML5 & CSS3 效果【附源码下载】
这里集合的这组 HTML5 & CSS3 效果,有的是网站开发中常用的.实用的功能,有的是先进的 Web 技术的应用演示.不管哪一种,这些案例中的技术都值得我们去探究和学习. 超炫的 HTML ...
- 优秀前端开发教程:超炫的 Mobile App 3D 演示
今天,我们想与您分享一个实验性的3D效果.它涉及到一个3D移动设备和一些移动应用程序截图.点击切换按钮时,我们将让移动设备转动并移动每个画面,使我们能看到一个分层的视图.你可能之前没见过这种应用程序演 ...
- 解决erlang节点启动失败报["inet_tcp",econnrefused]的问题
今天有同事说他机器上的leofs启动不了.我用console起了一下,发现报如下错: {error_logger,{{2015,11,3},{6,23,6}},"Protocol: ~tp: ...
- javascript学习4
JavaScript Date(日期)对象 日期对象用于处理日期和时间. JavaScript Date(日期)对象 实例 返回当日的日期和时间 如何使用 Date() 方法或者当日的日期. getT ...
- web项目中,视图层中关于相对路径和绝对路径
1.在jfinal项目中 因为一直使用的jfinal,没感觉路径问题. 举个栗子,项目名字叫做test.访问一个Controller的映射为/user/add.这样,在浏览器地址栏直接:localho ...