Diferencia entre revisiones de «Guía de hardening para servidores»
De TechShareRoom wiki
Más acciones
| Línea 18: | Línea 18: | ||
=Vulnerabilidades sysctl= | =Vulnerabilidades sysctl= | ||
<syntaxhighlight lang="bash "> | <syntaxhighlight lang="bash "> | ||
sudo nano /etc/sysctl.d/99-hardening.conf | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash "> | |||
# ─────────── Networking ─────────── | |||
# Evitar source routing (protección contra ataques de red) | |||
net.ipv4.conf.all.accept_source_route = 0 | |||
net.ipv4.conf.default.accept_source_route = 0 | |||
# Reverse path filtering (prevención spoofing) | |||
net.ipv4.conf.all.rp_filter = 1 | |||
net.ipv4.conf.default.rp_filter = 1 | |||
# No enviar ICMP redirects | |||
net.ipv4.conf.all.send_redirects = 0 | |||
net.ipv4.conf.default.send_redirects = 0 | |||
# Logear paquetes martianos | |||
net.ipv4.conf.all.log_martians = 1 | |||
net.ipv4.conf.default.log_martians = 1 | |||
# Evitar que respondan a pings broadcast | |||
net.ipv4.icmp_echo_ignore_broadcasts = 1 | |||
# Habilitar TCP SYN cookies (previene SYN flood) | |||
net.ipv4.tcp_syncookies = 1 | |||
# ─────────── IPv6 hardening ─────────── | |||
net.ipv6.conf.all.accept_ra = 0 | |||
net.ipv6.conf.default.accept_ra = 0 | |||
net.ipv6.conf.all.accept_redirects = 0 | |||
net.ipv6.conf.default.accept_redirects = 0 | |||
# ─────────── Kernel security ─────────── | |||
# Deshabilitar IP forwarding (si no es router) | |||
net.ipv4.ip_forward = 0 | |||
net.ipv6.conf.all.forwarding = 0 | |||
# ─────────── Otros ─────────── | |||
# Logging y audit | |||
kernel.dmesg_restrict = 1 | |||
kernel.kptr_restrict = 2 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash "> | |||
sudo sysctl --system | sudo sysctl --system | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revisión del 13:35 27 dic 2025
Cambiar puerto ssh
sudo nano /etc/ssh/sshd_config
Port XX #any different to 22, IMPORTANT open port before!
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 3
LoginGraceTime 30#Refrescar
systemctl daemon-reload
systemctl restart ssh.socketVulnerabilidades sysctl
sudo nano /etc/sysctl.d/99-hardening.conf# ─────────── Networking ───────────
# Evitar source routing (protección contra ataques de red)
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Reverse path filtering (prevención spoofing)
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# No enviar ICMP redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
# Logear paquetes martianos
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
# Evitar que respondan a pings broadcast
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Habilitar TCP SYN cookies (previene SYN flood)
net.ipv4.tcp_syncookies = 1
# ─────────── IPv6 hardening ───────────
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
# ─────────── Kernel security ───────────
# Deshabilitar IP forwarding (si no es router)
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0
# ─────────── Otros ───────────
# Logging y audit
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2sudo sysctl --system