我关闭了 SSH 22 端口(以及我所替代的方案)
I close SSH port 22 (and what I use instead)

原始链接: https://www.michelebologna.net/2026/ssh-port-22-fwknop-single-packet-authorization/

标准的 SSH 加固(使用密钥和 `fail2ban`)仍会将 22 端口暴露给扫描器和潜在的零日漏洞。要真正保障服务器安全,应在用户证明身份之前让 SSH 服务处于不可达状态。 作者建议使用 **fwknop**(防火墙敲门守护程序)并配合 **单包授权 (SPA)**。与容易受到数据包嗅探和重放攻击的传统端口敲门(Port Knocking)不同,SPA 会向服务器发送一个经过加密且带有 HMAC 验证的 UDP 数据包。验证通过后,服务器会动态更新防火墙,在有限时间内为特定客户端 IP 开放 22 端口。 从攻击者的角度来看,服务器保持完全静默;22 端口显示为“已过滤”(关闭),从而有效消除了日志冗余并防止了针对 SSH 的漏洞攻击。 **实现细节:** * **自动化:** 服务器端的部署和防火墙规则通过 Ansible 管理。 * **无缝访问:** SSH 配置中的客户端 `ProxyCommand` 会自动执行敲门操作,使用户无需感知该过程。 * **冗余:** Tailscale 接口提供了一条独立的并行访问路径作为安全保障。 这种方法将 SSH 从面向互联网的服务转变为一种经过身份验证的“隐形”资源,显著减少了服务器的攻击面。

对不起。
相关文章

原文

Most SSH hardening guides stop at key-only auth and fail2ban. That helps, but if your machine has a public IP, port 22 is still open to the internet. Every automated scanner can probe it and get a response: the SSH version string, the banner, proof that something is listening.

The log noise alone is annoying: even with key-only auth, failed attempts pile up every day. But the bigger problem is exposure. If a zero-day drops in OpenSSH, every server with port 22 open is a target before you have time to patch. That has happened before.

I wanted the SSH daemon itself to be unreachable: no banner, no version string, nothing for nmap to work with. Not just rate-limited or hidden behind a non-standard port, but genuinely not connectable unless you already hold the key.

The idea: port knocking, and why it is not enough on its own