PHP Classes

File: firewall/ssh.sh

Recommend this page to a friend!
  Packages of Moises Espindola   Sentinela   firewall/ssh.sh   Download  
File: firewall/ssh.sh
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Sentinela
Linux protection tools with Web dashboard panel
Author: By
Last change:
Date: 6 days ago
Size: 1,882 bytes
 

Contents

Class file image Download
#!/usr/bin/env bash #============================================================================= # Sentinela ? Intelligent Linux Security Framework # firewall/ssh.sh ? Reglas específicas para SSH #============================================================================= # # Puerto configurable via PORT_SSH (default: 7890) # - Rate limit: SSH_RATE_LIMIT conexiones/minuto # - Connlimit: SSH_CONNLIMIT conexiones simultáneas por IP # - TRUSTED ipset bypassea límites #============================================================================= ssh_firewall_rules() { log_info "Configurando reglas SSH (puerto ${PORT_SSH})..." # ACCEPT para TRUSTED (ya está arriba en base_rules, pero no está de más) # Nota: TRUSTED ya acepta antes de llegar aquí # SSH con rate limit ${IPTABLES} -A "${CHAIN_INPUT}" -p tcp --dport "${PORT_SSH}" \ -m conntrack --ctstate NEW \ -m hashlimit --hashlimit-name SENTINELA_SSH \ --hashlimit-mode srcip \ --hashlimit-srcmask 32 \ --hashlimit-upto "${SSH_RATE_LIMIT}"/minute \ --hashlimit-burst "${SSH_RATE_LIMIT}" \ -j ACCEPT # SSH connlimit (máximo N conexiones simultáneas por IP) ${IPTABLES} -A "${CHAIN_INPUT}" -p tcp --dport "${PORT_SSH}" \ -m connlimit --connlimit-above "${SSH_CONNLIMIT}" \ --connlimit-mask 32 \ -j LOG --log-prefix "SENTINELA:SSH_CONNLIMIT: " --log-uid ${IPTABLES} -A "${CHAIN_INPUT}" -p tcp --dport "${PORT_SSH}" \ -m connlimit --connlimit-above "${SSH_CONNLIMIT}" \ --connlimit-mask 32 \ -j DROP # SSH existente (ESTABLISHED ya aceptado en base_rules, pero por si acaso) ${IPTABLES} -A "${CHAIN_INPUT}" -p tcp --dport "${PORT_SSH}" -j ACCEPT log_info "Reglas SSH aplicadas (puerto ${PORT_SSH}, rate ${SSH_RATE_LIMIT}/min, connlimit ${SSH_CONNLIMIT})" }