Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Close SSH on your VPS without locking yourself out

Most VPS images start with SSH open to the internet on port 22. That is convenient on day one, and it is also the port that gets scanned all day. Closing it is a good idea. Doing it in the wrong order is how people lock themselves out of a box they still need. You can close SSH safely. You just need another way to reach the server, a firewall that matches what you think is open, and a way to…

Many virtual private server (VPS) setups leave SSH open to the internet on port 22, which makes it a frequent target for scans. However, closing SSH can leave you locked out of your server if you don't have an alternative way to access it. To safely close SSH, you first need another method to reach the server, such as the provider's console, a private network connection, or a management agent that allows you to run commands.

Additionally, you must ensure your firewall rules match your expectations and have a way to deploy and debug without relying on an open inbound port. When closing SSH, remember that two things must be true: sshd is not reachable from the internet and the firewall is blocking port 22. It's crucial to verify what the server is already listening on before making any changes, as a forgotten service could inadvertently remain open.

Harden SSH by disabling password authentication and limiting root logins. After confirming you can still connect using a key, you can further restrict SSH access. Implementing a default-deny firewall policy helps protect against potential vulnerabilities. The "outbound-only" approach involves using an agent on the server to communicate with external services, rather than relying on SSH.

Once you've established an alternate access method, you can safely close port 22 in both your host firewall and the cloud security group. Keep a key on hand as a last resort, but ensure the server is still accessible from outside your allowed networks. Using a control plane like Unrent can automate this process, keeping your server hardened while providing easy access when needed.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Report a problem with this story

Get the day's news by email. Daily, weekly or monthly. Sign up

More in Tech

More from Wednesday, 2 December 2026 →