This commit is contained in:
Toby
2026-01-27 17:35:45 -05:00
commit 2639af6531
176 changed files with 27104 additions and 0 deletions
@@ -0,0 +1,111 @@
# SSH Server Hardening Configuration
# Place in /etc/ssh/sshd_config.d/hardening.conf
# Restart SSH: systemctl restart sshd
#------------------------------------------------------------------------------
# AUTHENTICATION
#------------------------------------------------------------------------------
# Disable root login
PermitRootLogin no
# Disable password authentication
PasswordAuthentication no
# Enable public key authentication
PubkeyAuthentication yes
# Disable empty passwords
PermitEmptyPasswords no
# Disable keyboard-interactive authentication
KbdInteractiveAuthentication no
# Disable challenge-response authentication
ChallengeResponseAuthentication no
# Maximum authentication attempts
MaxAuthTries 3
# Maximum sessions per connection
MaxSessions 2
# Maximum simultaneous unauthenticated connections
MaxStartups 10:30:60
# Login grace time
LoginGraceTime 60
#------------------------------------------------------------------------------
# SESSION
#------------------------------------------------------------------------------
# Client alive settings (timeout)
ClientAliveInterval 300
ClientAliveCountMax 2
# Disable TCP forwarding
AllowTcpForwarding no
# Disable agent forwarding
AllowAgentForwarding no
# Disable stream local forwarding
AllowStreamLocalForwarding no
# Disable X11 forwarding
X11Forwarding no
# Disable user environment processing
PermitUserEnvironment no
# Disable tunnel device forwarding
PermitTunnel no
# Disable gateway ports
GatewayPorts no
#------------------------------------------------------------------------------
# CRYPTOGRAPHY
#------------------------------------------------------------------------------
# Protocol version (SSH-2 only)
Protocol 2
# Strong ciphers only
Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
# Strong MACs only
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
# Strong key exchange algorithms
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
# Strong host key algorithms
HostKeyAlgorithms ssh-ed25519,rsa-sha2-512,rsa-sha2-256
#------------------------------------------------------------------------------
# LOGGING
#------------------------------------------------------------------------------
# Log level
LogLevel VERBOSE
# Enable sftp logging
Subsystem sftp /usr/lib/openssh/sftp-server -l INFO
#------------------------------------------------------------------------------
# ACCESS CONTROL
#------------------------------------------------------------------------------
# Use PAM
UsePAM yes
# Show banner
Banner /etc/issue.net
# Restrict to specific users (uncomment and customize)
# AllowUsers admin deploy
# Restrict to specific groups (uncomment and customize)
# AllowGroups sshusers admins
@@ -0,0 +1,104 @@
# Linux Kernel Security Hardening
# Place in /etc/sysctl.d/99-security.conf
# Apply with: sysctl -p /etc/sysctl.d/99-security.conf
#------------------------------------------------------------------------------
# NETWORK SECURITY
#------------------------------------------------------------------------------
# Disable IP forwarding (unless router)
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0
# Disable packet redirect sending
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
# Disable ICMP redirect acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
# Disable source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
# Log suspicious packets
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
# Ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Ignore bogus ICMP error responses
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Enable reverse path filtering (spoofing protection)
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# Enable TCP SYN cookies (SYN flood protection)
net.ipv4.tcp_syncookies = 1
# Disable IPv6 router advertisements
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
# Disable IPv6 if not needed
# net.ipv6.conf.all.disable_ipv6 = 1
# net.ipv6.conf.default.disable_ipv6 = 1
#------------------------------------------------------------------------------
# KERNEL SECURITY
#------------------------------------------------------------------------------
# Enable ASLR
kernel.randomize_va_space = 2
# Restrict access to kernel pointers
kernel.kptr_restrict = 2
# Restrict dmesg access
kernel.dmesg_restrict = 1
# Restrict ptrace scope
kernel.yama.ptrace_scope = 1
# Disable magic SysRq key
kernel.sysrq = 0
# Restrict unprivileged user namespaces
# kernel.unprivileged_userns_clone = 0
# Restrict loading TTY line disciplines
dev.tty.ldisc_autoload = 0
# Restrict userfaultfd to privileged users
vm.unprivileged_userfaultfd = 0
# Restrict BPF
kernel.unprivileged_bpf_disabled = 1
net.core.bpf_jit_harden = 2
# Restrict perf events
kernel.perf_event_paranoid = 3
#------------------------------------------------------------------------------
# FILE SYSTEM SECURITY
#------------------------------------------------------------------------------
# Restrict core dumps
fs.suid_dumpable = 0
# Restrict hardlinks and symlinks
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
# Protect FIFOs and regular files
fs.protected_fifos = 2
fs.protected_regular = 2