Guide
Harden a new VPS in one command (beta)
Last updated: 3 December 2026
This free script does the three things most people should do on a new server: a normal sudo user, SSH without passwords and a firewall. It is new (beta): read it first and try DRY_RUN=1.
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 (430e8d41d3f58b54f491dd0d0d54bd538a0b95e31389c8129e7c73f741998f10), read it, then run:
wget https://phantomvps.com/blog/harden.sh
sha256sum harden.sh
less harden.sh
sudo NEW_USER=alice bash harden.sh
What it changes
- With NEW_USER=name: creates that user in the sudo group, asks for its password and copies root's SSH keys to it
- Only if a working SSH key is installed: turns off password logins and allows root only with a key (file /etc/ssh/sshd_config.d/00-phantom-hardening.conf)
- Turns on ufw: deny incoming, allow outgoing, SSH port open with rate limiting
Good to know
- Without an SSH key it leaves password logins on and tells you to add a key first
- DRY_RUN=1 shows every step without changing anything
- Keep your session open and test a new login in a second window before you log out
- Other services need their own firewall rule, for example ufw allow 443/tcp
Questions and answers
How do I undo it?
Delete /etc/ssh/sshd_config.d/00-phantom-hardening.conf, reload ssh and run ufw disable.
Will it lock me out?
It changes SSH only when a key is installed and checks the new settings with sshd -t first. Still, test a new login before closing your session.
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