Skip to content

Instantly share code, notes, and snippets.

@shuanghua
Created July 19, 2020 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuanghua/b09430e6191520638a1cdc83924a5797 to your computer and use it in GitHub Desktop.
Save shuanghua/b09430e6191520638a1cdc83924a5797 to your computer and use it in GitHub Desktop.
debian ufw 防火墙安装

安装 ufw

sudo apt install ufw
sudo ufw allow OpenSSH                         //让 ufw 允许 ssh 连接,避免后续连接不上 vps

如果SSH服务器 ssh 登录的端口不是 22 ,则还必须需要打开该端口。

  • 例如,您的 ssh 服务器监听端口为 7722,您还需要执行:
sudo ufw allow 7722/tcp

启用 ufw

sudo ufw enable      //输入 y 回车完成启用

开放 443 或 80

  • 443
sudo ufw allow https

或者

sudo ufw allow 443/tcp
sudo ufw allow 443/udp
  • 80
sudo ufw allow http

或者

sudo ufw allow 80/tcp
sudo ufw allow 80/udp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment