Unified SSH hardening, configuration management, and rollback system for Proxmox LXC containers and VMs running Debian/Ubuntu.
# Complete SSH management suite with unified interface
curl -fsSL https://raw.githubusercontent.com/ValkyrieNexus/proxmox-ssh-hardening/main/ssh-management-suite.sh | sudo bash# Download the suite
wget https://raw.githubusercontent.com/ValkyrieNexus/proxmox-ssh-hardening/main/ssh-management-suite.sh
# Make it executable
chmod +x ssh-management-suite.sh
# Review the script (recommended)
less ssh-management-suite.sh
# Run the suite
sudo ./ssh-management-suite.shWhen you run the suite, you'll see this main menu:
SSH Management Suite v3.0
===============================
Host: your-hostname
Current SSH Port: 22
1) Harden SSH (new installation)
2) Configure multi-IP access
3) Manage/rollback previous sessions
4) Validate current configuration
5) Exit
- Complete SSH security hardening for fresh systems
- Encrypted key generation (Ed25519 + RSA-4096)
- Automatic user creation with sudo privileges
- Port configuration (default: 2222)
- Network access restrictions (optional)
- Socket activation handling (fixes port binding issues)
- Perfect for multi-location setups (office + home networks)
- CIDR subnet support (
192.168.1.0/24) - Specific IP addresses (
10.0.0.100) - Hostname support for dynamic IPs
- Input validation and configuration testing
- Session discovery (finds all previous hardening)
- Interactive rollback with detailed session info
- Automated rollback scripts + manual restoration
- Safe restoration with configuration testing
- Comprehensive testing of SSH security settings
- Port binding verification
- Service status checking
- Key file validation
- Security audit with detailed reporting
- β Disable root login and password authentication
- β Change SSH port (default: 2222, customizable)
- β Strong encryption algorithms (Ed25519, modern ciphers)
- β Connection limits (MaxAuthTries, MaxSessions, timeouts)
- β User access restrictions via AllowUsers directive
- β Encrypted Ed25519 keys (recommended, quantum-resistant)
- β RSA-4096 keys (legacy compatibility)
- β Strong random passphrases (32-character entropy)
- β Automatic key installation to authorized_keys
- β Proper file permissions (600 for private keys)
- β
CIDR notation for subnets (
192.168.1.0/24) - β
Specific IP addresses (
10.0.0.100) - β Hostname support for dynamic IPs
- β Multiple location access (office, home, VPN)
- β Automatic backups of all modified files
- β Rollback scripts generated for emergency recovery
- β Configuration validation before applying changes
- β Service testing before restart
- Debian 10+, Ubuntu 18.04+, or Proxmox LXC/VM
- Root access (sudo privileges)
- Active internet connection
- Proxmox console access (critical for recovery)
# SSH into your server
ssh root@your-server-ip
# Run the management suite
curl -fsSL https://raw.githubusercontent.com/ValkyrieNexus/proxmox-ssh-hardening/main/ssh-management-suite.sh | sudo bash# SSH into your server
ssh root@your-server-ip
# Download the suite
wget https://raw.githubusercontent.com/ValkyrieNexus/proxmox-ssh-hardening/main/ssh-management-suite.sh
# Make executable
chmod +x ssh-management-suite.sh
# Review the script (optional but recommended)
less ssh-management-suite.sh
# Run the suite
sudo ./ssh-management-suite.shThe suite will display the main menu:
SSH Management Suite v3.0
===============================
Host: your-hostname
Current SSH Port: 22
1) Harden SSH (new installation)
2) Configure multi-IP access
3) Manage/rollback previous sessions
4) Validate current configuration
5) Exit
For fresh LXC/VM installations:
- Select Option 1 from the main menu
- Configure settings when prompted:
- Admin username (default:
admin) - SSH port (default:
2222) - Network restrictions (optional:
192.168.1.0/24)
- Admin username (default:
- Key generation (recommended: both Ed25519 + RSA-4096)
- Apply hardening (disables root login, passwords, etc.)
- Service restart (handles socket activation automatically)
Critical: Test connection immediately:
# The script provides exact command like:
ssh -i /root/ssh-generated-keys-TIMESTAMP/admin_ed25519 -p 2222 admin@your-server-ipPerfect for MacBook users with office/home access:
- Select Option 2 from the main menu
- Enter your username (must exist on system)
- Add network ranges one by one:
Enter network/IP (empty to finish): 10.0.0.0/8 # Office/Teleport Enter network/IP (empty to finish): 192.168.1.0/24 # Home network 1 Enter network/IP (empty to finish): 192.168.50.0/24 # Home network 2 Enter network/IP (empty to finish): [press Enter] - Review and apply the configuration
- Test connections from each location
If you need to undo changes:
- Select Option 3 from the main menu
- View available sessions (automatically discovered)
- Choose a session to examine details
- Execute rollback (automated script + manual options)
- Verify restoration (automatic SSH service restart)
To verify your SSH security:
- Select Option 4 from the main menu
- Review test results (port binding, security settings, etc.)
- Check recommendations for any failed tests
- Get connection examples for your current setup
After initial hardening, you need to get your SSH keys:
# From your local machine (Mac/Linux)
mkdir -p ~/.ssh/proxmox-keys
# Download private key
scp -P 2222 admin@your-server-ip:/root/ssh-generated-keys-TIMESTAMP/admin_ed25519 ~/.ssh/proxmox-keys/
# Download key information (contains passphrases)
scp -P 2222 admin@your-server-ip:/root/ssh-generated-keys-TIMESTAMP/ALL_PUBLIC_KEYS.txt ~/.ssh/proxmox-keys/
# Set proper permissions
chmod 600 ~/.ssh/proxmox-keys/admin_ed25519# On the server, display the private key
cat /root/ssh-generated-keys-TIMESTAMP/admin_ed25519
# On your local machine, create the key file
nano ~/.ssh/proxmox-keys/admin_ed25519
# Paste the key content, save with Ctrl+X, Y, Enter
# Set permissions
chmod 600 ~/.ssh/proxmox-keys/admin_ed25519
# Get the passphrase
cat /root/ssh-generated-keys-TIMESTAMP/ALL_PUBLIC_KEYS.txt# Add to ~/.ssh/config
nano ~/.ssh/config
# Add entry:
Host my-proxmox-server
HostName your-server-ip
Port 2222
User admin
IdentityFile ~/.ssh/proxmox-keys/admin_ed25519
IdentitiesOnly yes
# Connect with:
ssh my-proxmox-server- Open Termius
- Add new host:
- Alias:
Proxmox Server - Hostname:
your-server-ip - Port:
2222 - Username:
admin
- Alias:
- Import key: Settings β Keys β Import β Select private key
- Enter passphrase from ALL_PUBLIC_KEYS.txt
The SSH Management Suite can be run anytime for:
- Adding new network ranges (Option 2)
- Rolling back changes (Option 3)
- Validating configuration (Option 4)
- Re-running hardening (Option 1)
Simply run the suite again:
sudo ./ssh-management-suite.shThe suite automatically tracks all SSH modifications and provides comprehensive session management:
- Session Discovery: Automatically finds previous hardening sessions
- Detailed History: View exactly what changes were made when
- Safe Rollbacks: Test configurations before applying rollbacks
- Selective Restoration: Choose which parts to rollback
Modern systemd systems use socket activation which can interfere with SSH port changes. The suite automatically:
- Detects socket conflicts that prevent port binding
- Safely disables ssh.socket when needed
- Preserves rollback capability for socket settings
- Handles service dependencies properly
Perfect for users who work from multiple locations:
# Example: MacBook user with office and home access
AllowUsers [email protected]/8 [email protected]/24 [email protected]/24This configuration allows SSH access from:
- Office network: 10.x.x.x (Teleport/UniFi/VPN)
- Home network 1: 192.168.1.x
- Home network 2: 192.168.50.x
The built-in validation system checks:
- Service Status: SSH daemon health and port binding
- Security Settings: Root login, password auth, key auth status
- File Permissions: Key files, authorized_keys, configuration files
- Network Configuration: Socket activation, port conflicts
- User Access: AllowUsers restrictions and authorized_keys setup
Option 1: Use Proxmox Console
- Access your LXC/VM via Proxmox web interface β Console
- Run the rollback manager:
sudo ./ssh-management-suite.shβ Option 3 - Select your session and rollback
Option 2: Direct Rollback Script
- Access via Proxmox console
- Find rollback script:
ls /root/ssh-*-rollback-*.sh - Execute:
sudo /root/ssh-hardening-rollback-TIMESTAMP.sh
Option 3: Manual SSH Config Restore
- Access via Proxmox console
- Restore config:
sudo cp /root/ssh-*-backups-*/sshd_config.*.bak /etc/ssh/sshd_config - Restart SSH:
sudo systemctl restart ssh
Always test your connection before closing existing sessions:
# Test from a NEW terminal window while keeping current session open
ssh -i ~/.ssh/proxmox-keys/admin_ed25519 -p 2222 admin@your-server-ip
# If connection fails, use Proxmox console to rollbackWhen you run Option 1 (Harden SSH), the following security measures are applied:
Authentication Security:
- Root login: DISABLED
- Password authentication: DISABLED
- Public key authentication: ENABLED
- Empty passwords: DISABLED
Connection Security:
- Custom SSH port (default: 2222)
- User access restrictions (AllowUsers)
- Maximum auth attempts: 3
- Login grace time: 30 seconds
- Client alive interval: 5 minutes
Protocol Security:
- Modern encryption algorithms only
- Strong key exchange methods
- Secure MAC algorithms
- Protocol version 2 enforced
Service Security:
- X11 forwarding: DISABLED
- Agent forwarding: DISABLED
- TCP forwarding: DISABLED
- Tunneling: DISABLED
- Ed25519 keys: Modern, quantum-resistant cryptography
- RSA-4096 keys: Legacy compatibility for older systems
- Encrypted private keys: Strong random passphrases (25+ characters)
- Proper permissions: 600 for private keys, 644 for public keys
- Secure storage: Keys stored in timestamped directories
SSH Connection Refused
# Check if SSH is running on correct port
sudo netstat -tlnp | grep :2222
sudo systemctl status ssh
# If not running on correct port, use the suite:
sudo ./ssh-management-suite.sh
# Choose Option 4 (Validate) to diagnose issuesPermission Denied (publickey)
# Verify key permissions on local machine
chmod 600 ~/.ssh/proxmox-keys/admin_ed25519
# Test with verbose SSH output
ssh -i ~/.ssh/proxmox-keys/admin_ed25519 -p 2222 -v admin@your-server-ip
# Check authorized_keys on server
sudo cat /home/admin/.ssh/authorized_keys
sudo ls -la /home/admin/.ssh/Socket Activation Issues
# The suite handles this automatically, but for manual fixes:
sudo systemctl stop ssh.socket
sudo systemctl disable ssh.socket
sudo systemctl mask ssh.socket
sudo systemctl restart sshValidation Failures
# Run comprehensive validation
sudo ./ssh-management-suite.sh
# Choose Option 4 (Validate)
# Or use standalone validation
curl -fsSL https://raw.githubusercontent.com/ValkyrieNexus/proxmox-ssh-hardening/main/ssh-validation.sh | sudo bash- Run validation first: Use Option 4 in the suite for detailed diagnostics
- Check service logs:
sudo journalctl -u ssh -f - Test SSH config:
sudo sshd -t - Use Proxmox console: Always available as backup access method
proxmox-ssh-hardening/
βββ ssh-management-suite.sh # Main unified interface
βββ ssh-validation.sh # Standalone validation tool
βββ README.md # This documentation
βββ LICENSE # MIT License
Contributions welcome! The suite is designed to be modular and extensible:
- Bug reports: Issues with specific distributions or edge cases
- Feature requests: Additional SSH security measures or convenience features
- Testing: Validation on different Debian/Ubuntu versions
- Documentation: Usage examples and troubleshooting guides
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for Proxmox homelab environments
- Optimized for multi-location access scenarios
- Designed with safety and recoverability in mind
- Handles modern systemd complexities (socket activation, etc.)
Caution. Keep Proxmox console access available as a backup method.