linux系统配置二次登录

centos系统

安装动态口令

   yum install google-authenticator -y
   yum -y install mercurial pam-devel
    google-authenticator 

#出现这个二维码的时候使用动态口令app扫描下

image-20240411161340524

image-20240411161629067

修改用户配置

vim /etc/pam.d/sshd 
auth required pam_google_authenticator.so


vim /etc/ssh/sshd_config 
ChallengeResponseAuthentication yes


image-20240411161943294

image-20240411162133426

重启ssh,登录测试

image-20240411163638882

image-20240411163716927

image-20240411163742712

image-20240411163756101

image-20240411163902226

动态口令输入3次用户锁定30秒

其它用户配置

只要用户设置了二次认证,其它用户也要设置下,不然登录不上去。

可以把

image-20240411165014296

image-20240411165502513

ubuntu系统安装

安装

 apt-get install libpam-google-authenticator 
 google-authenticator 


出现二维码后,先扫描。然后输入动态口令

image-20240411170234123

image-20240411170347973

image-20240411170455347

修改ssh

vim /etc/pam.d/sshd 
auth required pam_google_authenticator.so

vim /etc/ssh/sshd_config

image-20240411170606396

image-20240411170859100

登录方式和centos一样

取消二次登录

#这两个配置文件添加的配置删除,重启sshd服务,如果登录不上系统,进入单用户密码修改
vim /etc/pam.d/sshd 

vim /etc/ssh/sshd_config
posted @   挖挖挖  阅读(91)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示