avatar

瓜生花子八宝粥

少壮不努力 老了看浏览器

  • 首页
  • 开源项目
  • Linux
  • Windows
  • Docker
  • 中间件
  • 数据库
主页 Linux 配置Google-Authenticator TOTF认证
文章

Linux 配置Google-Authenticator TOTF认证

发表于 2024-12-2 更新于 2024-12- 3
作者 jepwei
4~6 分钟 阅读

Google Authenticator 验证配置指南

本文将指导您如何在 CentOS 7 系统上安装和配置 Google Authenticator,以增强 SSH 登录的安全性。

1. 安装 Google Authenticator

使用以下命令安装 Google Authenticator:

rpm -ivh google-authenticator-1.04-1.el7.x86_64.rpm

2. 配置 SSHD 和 PAM

2.1 修改 PAM 配置

在 PAM 配置文件中添加 Google Authenticator 模块:

echo "auth required pam_google_authenticator.so" >> /etc/pam.d/sshd

2.2 修改 SSH 配置

编辑 SSH 配置文件以启用 PAM 和挑战响应认证:

vim /etc/ssh/sshd_config

确保以下行被设置为 yes:

UsePAM yes
ChallengeResponseAuthentication yes

2.3 重启 SSHD 服务

重启 SSH 服务以应用更改:

systemctl restart sshd

3. 配置 Google Authenticator

执行以下命令进行 Google Authenticator 的配置:

google-authenticator

注意: 在配置过程中,除了“Do you want to enable rate-limiting”选择 n 以外,其他选项均选择 yes。

4. 下载并配置手机应用

在手机上下载并安装身份验证应用:

  • iOS: Authenticator App 或其他身份验证软件
  • 安卓: Google Authenticator 或其他身份验证软件

使用应用扫描终端中显示的二维码。

5. 测试 SSH 登录

在 Xshell 或 SecureCRT 中使用 SSH 登录,设置为键盘交互模式。输入服务器密码后,再输入生成的随机验证码以成功登录服务器。

注意: 如果验证码失效,您可以通过 VNC 进入服务器,修改 /etc/ssh/sshd_config 中的 UsePAM 为 no,然后重启 SSHD 服务以恢复访问。

注意事项

  1. 备份密钥: 确保在配置 Google Authenticator 时备份生成的密钥,以防丢失访问权限。
  2. 安全性: 使用 Google Authenticator 可以显著提高 SSH 登录的安全性,但请确保您的服务器安全配置得当。

通过以上步骤,您可以成功配置 Google Authenticator,增强 SSH 登录的安全性。

Linux
Linux
许可协议: 
分享

相关文章

7月 16, 2025

ubuntu 设置时间显示为24小时制

对ubuntu默认的时间显示格式不太满意,查阅了相关资料进行修改为24小时制度,特此记录和分享给需要设置的网友 查看当前的timezone root@jumpserver:~# timedatectl Local time: Sat 2024-03-23 12:45:5

6月 10, 2025

KVM 虚拟机创建模板

查看--os-type支持的参数 osinfo-query os # 列出所有已知操作系统 win7 virt-install --name=win7_zpcl_ip --vcpu=8,sockets=1,cores=8,threads=1 --ram=16384 --disk path=/home

1月 15, 2025

cpu 内存占用脚本

本文介绍了两个版本的Linux压力测试脚本,分别用于CPU和内存的压力测试。CPU压力测试脚本通过无限循环创建指定数量的进程以占用CPU资源;内存压力测试脚本则通过创建临时内存块来模拟内存占用,支持指定大小和停止运行。用户需根据用法说明参数执行脚本。该文档适合需要进行性能测试的Linux用户。

下一篇

Linux 配置ssh

上一篇

Linux 本地yum源搭建

最近更新

  • 1panel 部署
  • jumpserver 堡垒机部署
  • ubuntu 设置时间显示为24小时制
  • pritunl vpn 部署
  • dockovpn 部署

热门标签

nacos openvpnas 资源分享 docker oracle mysql ubuntu 开源项目 虚拟化 Linux

目录

©2025 瓜生花子八宝粥. 保留部分权利。

使用 Halo 主题 Chirpy