Guide
Fail2ban one-command SSH protection (beta)
Last updated: 1 December 2026
This free script installs Fail2ban and protects SSH on the ports your server really uses. It is new (beta): read it first.
Instant 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 and delivered in about 10 minutes.
- New VPS orders have a 24-hour guarantee (see the terms for what is covered).
See Instant VPS plansHow ordering worksRequirements and run
Ubuntu 22.04/24.04 or Debian 12/13 with root access, at any provider. Download, compare the SHA-256 (60d38f27c35c186cb02d89270267c01420841585f6275e2e849adf641d8eb5bd), read it, then run:
wget https://phantomvps.com/blog/fail2ban.sh
sha256sum fail2ban.sh
less fail2ban.sh
sudo bash fail2ban.sh
What it changes
- Installs fail2ban
- Writes one file: /etc/fail2ban/jail.d/sshd-local.local
- Bans an address for 1 hour after 5 failures in 10 minutes (adjustable)
- Does not change SSH settings or passwords
Good to know
- Fail2ban slows down guessing; SSH keys are still the stronger protection
- With sudo, your own address may not be detected; add it to ignoreip if you want it never banned
- Unban with: fail2ban-client set sshd unbanip ADDRESS
Questions and answers
Can it lock me out?
Repeated wrong logins from your address get it banned for the ban time. Your provider console still works.
How do I change the limits?
Set MAXRETRY, BANTIME or FINDTIME when running it.
Is it tested?
It is a beta. Please report problems to support@phantomvps.com.
Does it work on other providers?
Yes, on any server with a supported system and root access.
Ready to try it? Instant VPS from $7.99 a month
- Pick a plan: Instant 1-2, $7.99 a month or all Instant 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 and delivered in about 10 minutes.
- 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 Instant VPS plansHow ordering works