设为首页 收藏本站
查看: 1300|回复: 0

[经验分享] SSH使用Google Authenticator二次验证

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-11-5 08:08:03 | 显示全部楼层 |阅读模式
QQ截图20141105080636.jpg

基本的原理如上图:
客户端在输入code码之后,才可以输入服务器的密码,进行账户验证,方可进入服务器。
实现方式如下:
1. 安装所需组件
# yum -y install mercurial pam-devel
2.  安装qrencode,在Linux上,有一个名为 QrenCode 的命令行工具可以很容易帮我们生成二维码,google authenticator命令行生成二维码就是调用它。
# tar zxfqrencode-3.3.1.tar.gz
# cdqrencode-3.3.1
# ./configure--prefix=/usr && make && make install
3. 安装GoogleAuthenticator
# tar jxvf libpam-google-authenticator-1.0-source.tar.bz2
# cd libpam-google-authenticator-1.0
# make && make install
4. SSH登录时调用google-authenticator模块
vim /etc/pam.d/sshd
在第一行添加如下:
auth       required    pam_google_authenticator.so
vim /etc/ssh/sshd_config
ChallengeResponseAuthenticationyes #开启此行
UsePAM yes #添加此行
Service sshd restart
5. 生成google-authenticator配置
google-authenticator
Do youwant authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@node3.mengtao.com%3Fsecret%3DABEXG5K6CVB56BXY
#此网址为生成的二维码,客户端扫描
Your newsecret key is:node3.mengtao.com
Yourverification code is 582849
Youremergency scratch codes are:
  30776626
  14200155
  80795568
  23936997
  21919909
#上面几行数字为应急码
Do youwant me to update your "/root/.google_authenticator" file (y/n) y
#更新配置文件
Do youwant to disallow multiple uses of the same authentication
token?This restricts you to one login about every 30s, but it increases
yourchances to notice or even prevent man-in-the-middle attacks (y/n) y
#禁止一个口令多用
Bydefault, tokens are good for 30 seconds and in order to compensate for
possibletime-skew between the client and the server, we allow an extra
tokenbefore and after the current time. If you experience problems with poor
timesynchronization, you can increase the window from its default
size of1:30min to about 4min. Do you want to do so (y/n) n
#客户端与服务器时间误差
If thecomputer that you are logging into isn't hardened against brute-force
loginattempts, you can enable rate-limiting for the authentication module.
Bydefault, this limits attackers to no more than 3 login attempts every 30s.
Do youwant to enable rate-limiting (y/n) y
#次数限制
在设备上输入序列码和扫描二维码都可以
6. 登录验证
QQ截图20141105080658.jpg



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-27007-1-1.html 上篇帖子: 让centos系统支持自动加载NTFS移动硬盘 下篇帖子: Ubuntu 12.04 简单命令使用 Google
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表