惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
A
About on SuperTechFans
GbyAI
GbyAI
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 【当耐特】
博客园 - 司徒正美
博客园 - 聂微东
P
Proofpoint News Feed
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
博客园 - 叶小钗

eallion's Blog

春假清明自驾游 Ubuntu 25.10 安装和配置 秋假 彩礼 2025 博客变化 预制菜 联邦礼仪之一 重拾写博客的乐趣 少儿 TED - 时间管理大师 n8n 之同步博客到 Mastodon n8n 之备份 Mastodon 嘟文 如何备份 Mastodon Docker 部署 Mastodon NAS 折腾记 Windows 11 安装软件 博客排版 - 挤压中文标点符号 Hugo 博客集成 Mastodon 独立博客自省问卷 15 题 Chrome 插件更新:网址净化器 在 Hugo 中使用 Shiki 炒菜万能公式 uBlacklist 订阅合集 读《中文互联网正在加速崩塌》 CSS 和 JS 实现博客热力图 受灾小记 那,他吃什么?! Mastodon 同步到 Memos Hugo 外部链接跳转提示页面 联邦宇宙及 Mastodon 简介 2024 博客变化
SSH Google Authenticator
Charles Chin · 2016-09-08 · via eallion's Blog

我经常需要用 SSH 连加家到自己的电脑上,如果单独用密码验证,存在很多安全隐患,如果用密钥,又很麻烦,所以我选择的是用 Google 的双重验证。顺便换了一个非 22 端口。
下面的方法同样适用于 Ubuntu VPS,我的几个 VPS 都是这样设置的。

Ubuntu 16.04.1 LTS 64bit
OpenSSH server

# 1、安装 SSH 服务

sudo apt update
sudo apt install openssh-server

# 2、安装 Google-Authenticator

sudo apt update
sudo apt install libpam-google-authenticator

# 3、生成密钥

过程中全部按 y

# 4、配置手机 app

Google-Authenticator洋葱Authy身份宝 等扫描上一步生成的二维码即可。
我个人使用的是 Authy。

# 5、配置

添加:

auth required pam_google_authenticator.so

配置:

sudo vim /etc/ssh/sshd_config

修改:

ChallengeResponseAuthentication yes #改为 yes
port 22222 #SSH 默认使用 22 端口,这里看个人喜好修改成其他的或不修改

5、重启 SSH

使用时,Verification code:输入手机 app 生成的验证码即可。