Ir al contenido

基础Linux安全手册

Linux服务器加固指南

0阅读

本文档包含加固指南,该指南将系统地应用于 Portelcore 生态系统中的所有 Ubuntu 22.04 LTS 机器,以确保零信任环境。

在现代环境中,永远不应允许远程访问root,也不应使用简单密码。这些措施将应用于/etc/ssh/sshd_config:

Ventana de terminal
PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication no

2. 使用 UFW 和应用程序配置文件实施防火墙

Sección titulada «2. Implementar Firewall con UFW y Perfiles de Aplicación»

默认情况下,所有服务器的端口都将被阻止,除了 SSH(修改后的端口)和它们托管的应用程序特定的端口:

Ventana de terminal
ufw default deny incoming
ufw default allow outgoing
ufw allow 2222/tcp # Nuestro SSH endurecido
ufw allow 'Nginx Full'
ufw enable

为了减少攻击面和不必要的路由向量(如果本地基础设施不需要 IPv6):

将添加到/etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

最后,使用 sysctl -p 重新加载内核。