Loading

Linux Server enable Google Authenticator for Logon

使用 Google Authenticator

Google Authenticator 是一个开源的基于 TOTP(Time-based One-Time Password) 的 MFA 方案。

步骤 1:安装 Google Authenticator#

在 Linux 服务器(如 CentOS、Ubuntu)上安装:

sudo apt update && sudo apt install libpam-google-authenticator  # Ubuntu/Debian
sudo yum install epel-release && sudo yum install google-authenticator  # CentOS

步骤 2:配置 Google Authenticator#

运行以下命令:

google-authenticator

然后按照提示:

  • 选择 "Yes" 生成密钥
  • 记录 二维码 并在 Google Authenticator App(手机端)中扫描
  • 记录 密钥,以防以后恢复
  • 选择 "Yes" 更新 ~/.google_authenticator

步骤 3:修改 SSH 认证配置#

编辑 SSH 配置:

sudo nano /etc/ssh/sshd_config

找到 ChallengeResponseAuthentication no,改为:

ChallengeResponseAuthentication yes

保存后退出。

步骤 4:配置 PAM 认证#

编辑 PAM 配置文件:

sudo nano /etc/pam.d/sshd

在文件顶部添加:

auth required pam_google_authenticator.so

保存后退出。

步骤 5:重启 SSH 服务#

sudo systemctl restart sshd

现在,每次登录 SSH 都需要输入 Google Authenticator 生成的 6 位验证码。

作者:Jas0n0ss

出处:https://www.cnblogs.com/Jas0n0ss/p/18720803

版权:本作品采用「MIT」许可协议进行许可。

posted @   Jas0n0ss  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
more_horiz
keyboard_arrow_up light_mode palette
选择主题
menu
点击右上角即可分享
微信分享提示