三二互联专业提供速度最快最稳定的美国服务器、香港服务器。中美直连,亚洲优化![ 代理登陆 ] [ 付款方式 ] [ 找回密码 ][ 电子协议责任书 ]
硬件资源保障

采用高配品牌服务器

主流强悍CPU配置

确保服务高速稳定运行

中美直连线路

中美直连亚洲优化

采用中国CN2骨干网络

保证速度飞快稳定高效

如何避免服务器被暴力破解?

美国、香港服务器

如何避免服务器被暴力破解?

05-21   来源:

 一、基础硬核防护(必做)

1. 修改 SSH 默认 22 端口
bash
运行
vi /etc/ssh/sshd_config
Port 2266  # 自定义高位端口
放行端口并删除 22 端口
bash
运行
firewall-cmd --permanent --add-port=2266/tcp
firewall-cmd --permanent --remove-port=22/tcp
firewall-cmd --reload
systemctl restart sshd
2. 禁止 root 账号远程登录
bash
运行
vi /etc/ssh/sshd_config
PermitRootLogin no
systemctl restart sshd
3. 彻底关闭密码登录,只允许密钥登录
ini
PasswordAuthentication no
ChallengeResponseAuthentication no
PermitEmptyPasswords no
PubkeyAuthentication yes
重启 SSH
bash
运行
systemctl restart sshd
做完这一步:暴力破解直接彻底失效
4. 关闭 SSH 反向 DNS 解析
ini
UseDNS no
二、IP 白名单限制(最强防护)
只允许自己 IP 连接 SSH,全网其他 IP 全部拦截
bash
运行
# 仅放行你的本地IP
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="你的IP/32" port protocol="tcp" port="2266" accept"
# 拒绝所有其他IP访问SSH端口
firewall-cmd --permanent --add-rich-rule="rule port protocol="tcp" port="2266" reject"
firewall-cmd --reload
三、安装自动拉黑工具 fail2ban
自动拉黑频繁输错密码 IP
bash
运行
dnf install fail2ban -y
systemctl enable --now fail2ban
简单配置:5 次失败封禁 10 分钟
bash
运行
vi /etc/fail2ban/jail.local
写入
ini
[sshd]
enabled = true
maxretry = 5
bantime = 600
findtime = 300
重启
bash
运行
systemctl restart fail2ban
四、限制登录用户范围
只允许指定用户登录 SSH
bash
运行
vi /etc/ssh/sshd_config
AllowUsers admin user01
只写允许登录的账号,其余全部禁止
五、缩短登录超时时间
ini
# 无操作1分钟断开
ClientAliveInterval 60
ClientAliveCountMax 2
六、防火墙全局安全策略
只开放 80、443、自定义 SSH 端口
关闭高危端口:3306、21、3389、8080 等
不对外网开放数据库、FTP 端口
七、日常安全习惯
私钥本地设置密码保护
定期轮换 SSH 密钥,设置密钥有效期
不用弱口令,所有服务密码高强度
不随意开放服务器权限、不下载陌生脚本
定期查看 /var/log/secure 登录日志
八、最终无敌防护组合
改端口 + 禁 root 登录 + 关闭密码登录 + 密钥登录 + IP 白名单
这套组合全开,99.9% 暴力破解完全无效
九、快速一键加固命令
bash
运行
sed -i "s/^#Port 22/Port 2266/" /etc/ssh/sshd_config
sed -i "s/^PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
sed -i "s/^#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
sed -i "s/^PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
systemctl restart sshd

三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快

上一篇:没有了 下一篇:如何查看服务器的日志文件?

美国GIA服务器三二互联版权所有 WWW.250.cc 2008-2015 All Rights Reserved
三二互联 - 专业的美国C3服务器香港vps、抗DOOS流量清洗、云备份系统、网站加速系统、美国GIA服务器和香港云服务器产品提供商
三二互联24小时在线工单系统为您提供全面、专业、周到的技术支持与服务
咨询热线:400-679-9994(免长话费)