Security & System Hardening

SSH Hardening Implementation

Duration: ~2 hours Date: February 2026 Status: Production
TL;DR

Rolled out Ed25519 key-based authentication and fail2ban across 6 systems — 3 Proxmox hypervisors and 3 Linux VMs. Did it without a single lockout by testing in a parallel session before closing the existing one. Password authentication is now disabled everywhere. A fourth Proxmox node (pve04) joined in October 2026 with the same config, so it now covers 7 systems.

Key Achievement: No system accepts password authentication. fail2ban bans IPs after 5 failures — slows attackers without risking permanent self-lockout.
$ cat results.txt
password logins
disabled on every system
systems
7 (4 Proxmox nodes + 3 Linux VMs)
lockouts
0 during the rollout
fail2ban
ban after 5 failures in a 10-minute window

The Problem

My homelab infrastructure was accessible via Tailscale VPN for remote administration—a common and reasonable pattern. However, all systems used password-based SSH authentication, which creates several security risks:

Before (Vulnerable)

  • Password-based SSH on all systems
  • Unlimited authentication attempts
  • No automated threat response
  • Single factor (password only)
  • Compromised password = full access

After (Hardened)

  • Ed25519 key-based authentication
  • Password authentication disabled
  • fail2ban monitoring all access
  • Automatic IP banning on failures
  • Defense-in-depth architecture

The risk model: if my Tailscale account were ever compromised, an attacker would have direct network access to infrastructure. Password-based SSH would then allow brute force attacks against any exposed system.

The Solution

Security Architecture

I implemented a defense-in-depth approach with two complementary layers:

┌─────────────────────────────────────────────────────────────────┐
│                    SSH HARDENING ARCHITECTURE                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│   LAYER 1: Authentication Hardening                             │
│   ┌─────────────────────────────────────────────────────────┐   │
│   │  Ed25519 Key-Based Authentication                       │   │
│   │  • Private key never leaves client device               │   │
│   │  • Public key deployed to all servers                   │   │
│   │  • Password authentication completely disabled          │   │
│   └─────────────────────────────────────────────────────────┘   │
│                              │                                   │
│                              ▼                                   │
│   LAYER 2: Intrusion Prevention                                 │
│   ┌─────────────────────────────────────────────────────────┐   │
│   │  fail2ban Active Monitoring                             │   │
│   │  • Watches /var/log/auth.log for failures               │   │
│   │  • 5 failed attempts → 10-minute IP ban                 │   │
│   │  • VPN network whitelisted to prevent self-lockout      │   │
│   └─────────────────────────────────────────────────────────┘   │
│                                                                  │
├─────────────────────────────────────────────────────────────────┤
│   SYSTEMS PROTECTED                                              │
│   • 3 Proxmox Hypervisors (root with keys, prohibit-password)   │
│   • 3 Linux VMs (user account + sudo, root login disabled)      │
└─────────────────────────────────────────────────────────────────┘
                

Different Security Models by System Type

Enterprise environments treat hypervisors differently from application servers. I applied the same principle:

Proxmox Hypervisors

PermitRootLogin prohibit-password
PasswordAuthentication no
PubkeyAuthentication yes

Root access required for Proxmox management, but only via SSH keys.

Linux VMs

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Root cannot SSH at all. User account with sudo for all admin tasks.

Implementation Details

Phase 1: SSH Key Deployment

Using existing Ed25519 keys (stored securely in password manager), I deployed public keys to all systems using ssh-copy-id:

# Deploy to each system, test immediately
ssh-copy-id root@proxmox-node
ssh root@proxmox-node  # Verify key auth works

ssh-copy-id user@linux-vm
ssh user@linux-vm      # Verify key auth works
Critical Safety Pattern: Always test SSH key authentication in a NEW terminal before closing your existing session. Keep the old session open as a safety net until the new one is verified working.

Phase 2: Disable Password Authentication

With key authentication verified on all systems, I disabled password auth:

# Edit SSH config
sudo nano /etc/ssh/sshd_config

# Verify changes
grep -E "^PermitRootLogin|^PasswordAuthentication|^PubkeyAuthentication" /etc/ssh/sshd_config

# Restart SSH service
sudo systemctl restart ssh    # Ubuntu/Debian VMs
systemctl restart sshd        # Proxmox nodes

Phase 3: Deploy fail2ban

Installed and configured fail2ban for automated intrusion prevention:

# Install
sudo apt update && sudo apt install fail2ban -y

# Create local config
sudo nano /etc/fail2ban/jail.local

Configuration applied:

[DEFAULT]
bantime = 10m
findtime = 10m
maxretry = 5
ignoreip = 127.0.0.1/8 ::1

[sshd]
enabled = true
port = ssh
logpath = /var/log/auth.log
backend = systemd
Why these settings:
  • 10-minute bans: Slows attackers without permanent blocks (avoids self-lockout)
  • 5 attempts: Balance between security and usability
  • VPN whitelist: Never ban legitimate remote access
  • /var/log/auth.log: Correct log path for Debian/Ubuntu/Proxmox

The Challenges

Challenge 1: fail2ban Couldn't Find Log File
▼

What Went Wrong:

ERROR Failed during configuration: Have not found any log file for sshd jail

The Problem:

Default fail2ban config looks for /var/log/sshd.log, but Debian/Ubuntu/Proxmox use /var/log/auth.log.

The Fix:

Created /etc/fail2ban/jail.local with explicit log path:

[sshd]
enabled = true
logpath = /var/log/auth.log
backend = systemd

Lesson Learned:

Always check distro-specific paths. Default configs assume RHEL/CentOS conventions that don't apply to Debian-family systems.

Challenge 2: SSH Service Name Varies by Distro
▼

What Went Wrong:

Failed to restart sshd.service: Unit sshd.service not found

The Problem:

Different distributions use different service names:

  • Ubuntu/Debian: Service is called ssh
  • RHEL/CentOS/Proxmox: Service is called sshd

The Fix:

# On Ubuntu/Debian VMs
sudo systemctl restart ssh

# On Proxmox nodes
systemctl restart sshd

Lesson Learned:

Know your target systems. This is exactly the kind of detail that matters when managing heterogeneous infrastructure.

Challenge 3: Proxmox Enterprise Repository 401 Errors
▼

What Went Wrong:

E: Failed to fetch https://enterprise.proxmox.com/... 401 Unauthorized

The Problem:

Proxmox comes with enterprise repository enabled by default, which requires a paid subscription.

The Fix:

# Disable enterprise repository
mv /etc/apt/sources.list.d/pbs-enterprise.list \
   /etc/apt/sources.list.d/pbs-enterprise.list.disabled

# Now apt update works
apt update && apt install fail2ban -y

Lesson Learned:

Proxmox defaults to enterprise repos. For homelab use, disable these or add the no-subscription repository.

Results

  • No system accepts password authentication anymore
  • Rolled out across all 6 systems without a single lockout
  • fail2ban bans IPs after 5 failed attempts — 10-minute window, which slows attackers without risking permanent self-lockout
  • Hypervisors and VMs use different security models for a reason (Proxmox needs root; VMs don't)

Verification

Confirmed hardening is working correctly:

# Test that password auth is disabled
$ ssh -o PubkeyAuthentication=no root@proxmox-node
Permission denied (publickey).

# Verify fail2ban is active
$ fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     0
|  `- File list:        /var/log/auth.log
`- Actions
   |- Currently banned: 0
   |- Total banned:     0
   `- Banned IP list:

The Short Version

All 6 systems in my homelab — 3 Proxmox hypervisors and 3 Linux VMs — were running password-based SSH accessible through Tailscale VPN. The VPN is the primary access control layer, but the risk model is: if a Tailscale account is ever compromised, an attacker has direct network-level access and password SSH becomes the only thing standing between them and the infrastructure. I implemented defense-in-depth: Ed25519 keys deployed via ssh-copy-id to all systems, password authentication disabled, and fail2ban with a 10-minute ban threshold after 5 failures. Hypervisors and VMs use different security models — Proxmox needs root access for management so those use PermitRootLogin prohibit-password, while application VMs disable root SSH entirely and use a user account with sudo. Zero downtime throughout: always test key auth in a new terminal before closing the existing session, never disable password auth until keys are verified.

Three failure modes worth documenting. fail2ban's default config looks for /var/log/sshd.log, which doesn't exist on Debian-family systems — they use /var/log/auth.log. This requires an explicit logpath override in jail.local. The SSH service name also differs: Ubuntu/Debian use ssh, Proxmox and RHEL-family use sshd — wrong name causes a systemd unit not found error. And on Proxmox Backup Server, trying to install fail2ban via apt fails with 401 Unauthorized because the enterprise repository is enabled by default and requires a paid subscription — disabling the enterprise list and optionally adding the no-subscription repo is required before any package installs.