Menu

How to Secure SSH on a Fresh VPS in 10 Minutes (Keys, Firewall, Fail2ban)
📰

How to Secure SSH on a Fresh VPS in 10 Minutes (Keys, Firewall, Fail2ban)

DEV Community: security·Buran Host·17 days ago
#QZSu9sCK
#devtosecurity#devto#dev#sudo#enter
Reading 0:00
15s threshold

Disclosure: I run Buran.host, a VPS hosting service. The steps below work on any Debian or Ubuntu server, no matter where it is hosted.

A new VPS is scanned by bots within minutes of getting a public IP address. Open the log of a fresh server and you will already see hundreds of failed root logins. None of this is dangerous if you spend ten minutes on setup first. Here is the short checklist I use on every new server.

1. Create a normal user

Do not work as root. Create a user and give it sudo rights:

adduser deploy usermod -aG sudo deploy

Enter fullscreen mode

Exit fullscreen mode

2. Log in with a key, not a password

On your own computer, create a key (skip this if you already have one):

ssh-keygen -t ed25519 -C "my-laptop" ssh-copy-id deploy@YOUR_SERVER_IP```

Open a second terminal and check that `ssh deploy@YOUR_SERVER_IP` logs you in without asking for the account password. Keep the first session open until this works. It is your safety net.

## 3.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.