Guide
Fail2ban on a VPS
Last updated: 15 November 2026
Any server with a public SSH port is probed all day by automatic login attempts. Fail2ban watches the logs and temporarily blocks addresses that keep failing. It is a good extra layer, but SSH keys (guide) and a firewall (guide) come first. If you are logged in as root, leave out sudo.
Fast VPS from $7.99 a month
- Sign up with an email address, a password and any nickname: no ID, no phone number.
- Pay with Monero, Bitcoin, Litecoin, USDT, USDC, SOL or TRX, or by card through MoonPay. Monero is the most private way to pay; USDT or USDC on Solana confirm in seconds, and we add no transfer fee on them.
- Orders are processed automatically: most are ready within minutes, occasionally it takes up to a few hours.
- New VPS orders have a 24-hour guarantee (see the terms for what is covered).
See Fast VPS plansHow ordering works
Install
sudo apt update
sudo apt install -y fail2ban
Configure SSH protection
Never edit jail.conf; create /etc/fail2ban/jail.local:
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 203.0.113.5
bantime = 1h
findtime = 10m
maxretry = 5
[sshd]
enabled = true
backend = systemd
port = ssh
Replace 203.0.113.5 with your own IP so a typing mistake cannot ban you (delete it if your home IP changes often), and change port if SSH runs on another port. Then:
sudo systemctl enable --now fail2ban
sudo systemctl restart fail2ban
sudo fail2ban-client status sshd
Everyday commands
- See who is banned:
sudo fail2ban-client status sshd.
- Lift a ban:
sudo fail2ban-client set sshd unbanip ADDRESS.
- Read the log:
sudo tail -n 50 /var/log/fail2ban.log.
If you ban yourself, use the emergency console (VNC) on your service page, if it shows one, and unban your address there.
Questions and answers
What does Fail2ban do?
It reads the logs and temporarily blocks addresses that fail to log in too many times.
Is Fail2ban enough to secure SSH?
No. Use SSH keys and a firewall first; Fail2ban is an extra layer.
How do I avoid banning myself?
Add your own IP to ignoreip in jail.local.
How do I lift a ban?
Run sudo fail2ban-client set sshd unbanip ADDRESS.
Ready to try it? Fast VPS from $7.99 a month
- Pick a plan: Fast 1-2, $7.99 a month or all Fast VPS plans.
- Sign up with an email address, a password and any nickname: no ID, no phone number.
- Pay with Monero, Bitcoin, Litecoin, USDT, USDC, SOL or TRX, or by card through MoonPay. Monero is the most private way to pay; USDT or USDC on Solana confirm in seconds, and we add no transfer fee on them.
- Orders are processed automatically: most are ready within minutes, occasionally it takes up to a few hours.
- New VPS orders have a 24-hour guarantee (see the terms for what is covered).
- Before you pay you can ping our test IPs and read the live status page.
- Support is available 24/7 via email and our client ticket portal.
See Fast VPS plansHow ordering works