VPS 安全分享 - 保护你的小鸡!

系统更新 确保你的系统是最新的,执行以下命令:

apt update && apt upgrade -y && apt dist-upgrade -y && apt full-upgrade -y && apt autoremove -y
reboot

SSH 安全

  1. 配置密钥登录:使用本地生成的 SSH 密钥,将公钥上传到服务器。
  2. 配置 sshd_config:编辑配置文件以增强安全性,建议只允许密钥登录。
nano /etc/ssh/sshd_config
# 示例配置,请根据实际情况调整
Port 22
PermitRootLogin no
PasswordAuthentication no

防火墙设置 使用 UFW 防火墙,只允许必要的端口。

apt install ufw -y
ufw default deny incoming
ufw default allow outgoing
ufw allow 22
ufw allow 443
ufw enable

Nginx 配置 保护 Nginx 不泄露源站证书:

cd /etc/nginx/conf.d
nano nxdomain.conf
server {
    listen 80 default_server;
    listen 443 ssl default_server;
    listen 443 quic reuseport;
    server_name _;
    ssl_reject_handshake on;
    return 444;
}

DNS 和 SSL 安全 避免 DNS 泄露,使用泛域名证书。

虚拟内网设置(Zerotier) 使用 Zerotier 构建虚拟内网,提高安全性。

Cloudflare ZeroTrust Tunnel 使用 Cloudflare 的 ZeroTrust Tunnel 功能,服务器不暴露 HTTPS 端口。

希望对新手有所帮助,欢迎交流分享!