CentOS7使用Google Authenticator

IT
IT
IT
335
文章
1
评论
2020年8月20日15:05:19 评论 793 2524字阅读8分24秒

简介

Google Authenticator(谷歌身份验证器),是谷歌公司推出的一款动态令牌工具,解决账户使用时遭到的一些不安全的操作进行的“二次验证”,认证器基于RFC文档中的HOTP/TOTP算法实现 ,是一种从共享秘钥和时间或次数一次性令牌的算法。在实际应用中可以通过认证器方式对账户有更好的保护

下面在CentOS7下利用Google Authenticator实现SSH登录的二次身份验证

配置EPEL源

[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# yum makecache

安装Google Authenticator

[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# yum install google-authenticator -y

google-authenticator初始化配置

  • 哪个账号需要动态验证码,切换到该账号下操作进行操作
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# google-authenticator

Do you want authentication tokens to be time-based (y/n) y
  • 屏幕提示Do you want authentication tokens to be time-based (y/n) ,回答y选用基于时间的token
  • 屏幕提示二维码,拿出手机打开google authenticator软件,点击+后选择“条形码扫描"添加认证条目。

CentOS7使用Google Authenticator

CentOS7使用Google Authenticator

Your new secret key is: UJ64PRAV7VLRY7ED4R6S43T3CM
Your verification code is 851470
Your emergency scratch codes are:
  43147520
  72365792
  24479114
  16355816
  30707562

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

By default, a new token is generated every 30 seconds by the mobile app.
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. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) y

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
  • 新建ssh连接(不要关闭当前的防止无法访问)测试配置是否成功。
  • 修改SSH登录相关配置文件参数
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# vim /etc/pam.d/sshd
auth required pam_google_authenticator.so
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# vim /etc/ssh/sshd_config
ChallengeResponseAuthentication yes
[root@iZ2ze2wuri2qoajwrtuzzyZ ~]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service

验证

  • 打开终端

CentOS7使用Google Authenticator

  • 使用Google Authenticator获取的动态码登陆
  • 使用zentermlite的键盘交互认证,第一次输入账号密码,第二次数据获取的动态吗

CentOS7使用Google Authenticator

CentOS7使用Google Authenticator

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年8月20日15:05:19
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
Eureka同步到nacos Nacos

Eureka同步到nacos

官方介绍文档地址 https://nacos.io/zh-cn/docs/nacos-sync.html 官方安装文档地址 https://nacos.io/zh-cn/docs/nacos-sync...
Eureka指定应用的instanceId为IP CentOS

Eureka指定应用的instanceId为IP

痛点 现在所有的应用指定的是服务器默认机器名称,对查看是哪一个服务IP或者单节点自动剔除服务不友好。 像如上图所示,想知道是哪一个节点,还得点开才能获取IP。 改造 全部改成自动获取服务器IP为ins...
阿里云网盘 CentOS

阿里云网盘

申请内测地址 https://survey.aliyun.com/apps/zhiliao/_o6XQjioM 官网地址 https://www.teambition.com/products/pan...
GitLab或Jenkins集成构建工具 CentOS

GitLab或Jenkins集成构建工具

集成构建工具 构建工具是用来将代码编译打包成制品的工具。例如前端项目我们一般使用npm进行打包,后端java项目我们一般使用maven、gradle进行打包。构建工具很多很多,但是集成到gitlab中...