Linux SSH安全提升核心是控制“谁、在什么条件下、能做什么”,通过身份认证加固(密钥登录替代密码)、访问入口收敛(限制用户/IP/监听地址)、操作行为约束(禁用root、限登录次数与超时)三道防线实现。

Linux SSH 安全提升,核心不是堆砌配置,而是控制“谁、在什么条件下、能做什么”。关键在三道防线:身份认证加固、访问入口收敛、操作行为约束。
用密钥替代密码登录
密码易被暴力破解或重放,密钥对(尤其是带密码的私钥)大幅提高门槛。生成时用 ssh-keygen -t ed25519 -C "your_email@example.com",优先选 ed25519 算法;公钥复制到服务器 ~/.ssh/authorized_keys 后,务必在 /etc/ssh/sshd_config 中设为:
- PubkeyAuthentication yes
- PasswordAuthentication no(确认密钥已生效再启用)
- PermitEmptyPasswords no
限制登录来源与用户范围
不给攻击面留“敞开的门”。通过 sshd_config 直接控制比防火墙更前置:
- AllowUsers user1@192.168.1.* user2@10.0.0.5 —— 只允特定用户从指定IP段登录
- DenyUsers root guest —— 明确禁止高危账户
- ListenAddress 192.168.1.100 —— 若仅内网管理,绑定内网IP,不监听公网
配合 ufw 或 iptables 限速(如每分钟最多3次新连接)效果更稳。
标签: linux word centos 防火墙 ubuntu ai
还木有评论哦,快来抢沙发吧~