当前位置: 首页 > news >正文

[svc]ssh+gg二步认证

1,安装依赖

yum install python-pip -y
pip install docutils 
yum install gcc python-devel subversion pam pam-devel  -y

2,下载git包

cd /home/lanny/tools/
unzip google-authenticator-master.zip 
cd google-authenticator-master
cd libpam/
./bootstrap.sh 
./configure 
make
make install 

3,配置文件

ll /lib64/security
google-authenticator,则复制到/usr/local/bin
ll /usr/local/bin/google-authenticator

#pl2pm /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so openvpn

4,为root用户生成google验证码

[root@vpnserver ~]# google-authenticator 
Do you want 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@vpnserver%3Fsecret%3D7ZSEKQI6W7GJXDDBEBJJINHY3Q%26issuer%3Dvpnserver
Your new secret key is: 7ZSEKQI6W7GJXDDBEBJJINHY3Q
Your verification code is 496552
Your emergency scratch codes are:
  70752164
  63976717
  73442435
  67261408
  95454901

修改pam.d
[root@vpnserver pam.d]# cat /etc/pam.d/sshd 
#%PAM-1.0
auth       required     pam_google_authenticator.so <---追加
auth       required pam_sepermit.so
auth       include      password-auth
account    required     pam_nologin.so
account    include      password-auth
password   include      password-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open env_params
session    optional     pam_keyinit.so force revoke
session    include      password-auth


=================================================
修改ssh配置:

vim /etc/ssh/sshd_config
 83 ChallengeResponseAuthentication yes

测试:手机下载google身份验证器,登陆(root用户哦)

====================================================
为jss生成:
jss 密码 sss
===============
[jss@vpnserver ~]$ google-authenticator 
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/jss@vpnserver%3Fsecret%3DLNS6P7ONML6LCOFPKXW4OFWYS4%26issuer%3Dvpnserver
Your new secret key is: LNS6P7ONML6LCOFPKXW4OFWYS4
Your verification code is 755883
Your emergency scratch codes are:
  41886633
  49746589
  44517353
  13151010
  41992403
=========================
注意:
1.如果无法登陆
cp /usr/local/lib/security/pam_google_authenticator.so /lib64/security/
2,
Google身份验证器每隔三十秒就会变的。这就实现了动态验证码的功能。
3,5个紧急验证码,用一个少一个.

4,
默认情况下,令牌只在30秒内有效,由于客户端和服务器时间不完全一致的因素,可以将时间窗口加大到最长4分钟
5,是否限制尝试次数,每30秒只能尝试最多3次:
6, google-authenticator针对单用户

参考

回滚为初始ssh状态

[root@vpnserver ~]# cat /etc/pam.d/ssh
cat: /etc/pam.d/ssh: No such file or directory
[root@vpnserver ~]# cat /etc/pam.d/sshd 
#%PAM-1.0
#auth       required     pam_google_authenticator.so # 注释掉即可

相关文章:

  • 文件上传到oss代码片段
  • Idea卡在Maven导入工程
  • 学习笔记 - Git
  • forget word out a~2
  • SSM-MyBatis-18:Mybatis中二级缓存和第三方Ehcache配置
  • 34.CSS传统布局【上】
  • 测试同学难道要写一辈子的hello world?
  • 扒一扒AR增强现实技术的专利态势
  • oracle em 5500访问问题
  • 笔记 OSPF多区域配置 STUB区域 路由重分发 NSSA区域配置
  • apache+tomcat配置负载均衡,实现http与websocket接口分压
  • C 语言整型谜题
  • React Router v4 学习笔记
  • Django--middleware 详解
  • AI降临——“人工智能女王”卡塞尔中国行
  • 【Leetcode】104. 二叉树的最大深度
  • 【vuex入门系列02】mutation接收单个参数和多个参数
  • Android开源项目规范总结
  • gitlab-ci配置详解(一)
  • SpiderData 2019年2月16日 DApp数据排行榜
  • uni-app项目数字滚动
  • 不上全站https的网站你们就等着被恶心死吧
  • 极限编程 (Extreme Programming) - 发布计划 (Release Planning)
  • 快速体验 Sentinel 集群限流功能,只需简单几步
  • 力扣(LeetCode)56
  • 深入浏览器事件循环的本质
  • 什么软件可以提取视频中的音频制作成手机铃声
  • 转载:[译] 内容加速黑科技趣谈
  • hi-nginx-1.3.4编译安装
  • #NOIP 2014#day.2 T1 无限网络发射器选址
  • (Java数据结构)ArrayList
  • (LNMP) How To Install Linux, nginx, MySQL, PHP
  • (Redis使用系列) Springboot 使用Redis+Session实现Session共享 ,简单的单点登录 五
  • (安全基本功)磁盘MBR,分区表,活动分区,引导扇区。。。详解与区别
  • (超详细)语音信号处理之特征提取
  • (第61天)多租户架构(CDB/PDB)
  • (附源码)spring boot儿童教育管理系统 毕业设计 281442
  • (六)软件测试分工
  • (论文阅读26/100)Weakly-supervised learning with convolutional neural networks
  • (一)80c52学习之旅-起始篇
  • (一)为什么要选择C++
  • .net 4.0 A potentially dangerous Request.Form value was detected from the client 的解决方案
  • .NET Core 控制台程序读 appsettings.json 、注依赖、配日志、设 IOptions
  • .NET/C# 使窗口永不获得焦点
  • .NET/C# 推荐一个我设计的缓存类型(适合缓存反射等耗性能的操作,附用法)
  • .NET框架设计—常被忽视的C#设计技巧
  • /etc/shadow字段详解
  • /var/log/cvslog 太大
  • ::
  • @CacheInvalidate(name = “xxx“, key = “#results.![a+b]“,multi = true)是什么意思
  • @DateTimeFormat 和 @JsonFormat 注解详解
  • [ C++ ] STL_stack(栈)queue(队列)使用及其重要接口模拟实现
  • [Android Pro] listView和GridView的item设置的高度和宽度不起作用
  • [ChromeApp]指南!让你的谷歌浏览器好用十倍!
  • [CQOI 2011]动态逆序对