All About Cookies is an independent, advertising-supported website. Some of the offers that appear on this site are from third-party advertisers from which All About Cookies receives compensation. This compensation may impact how and where products appear on this site (including, for example, the order in which they appear).
All About Cookies does not include all financial or credit offers that might be available to consumers nor do we include all companies or all available products. Information is accurate as of the publishing date and has not been provided or endorsed by the advertiser.
The All About Cookies editorial team strives to provide accurate, in-depth information and reviews to help you, our reader, make online privacy decisions with confidence. Here's what you can expect from us:
- All About Cookies makes money when you click the links on our site to some of the products and offers that we mention. These partnerships do not influence our opinions or recommendations. Read more about how we make money.
- Partners are not able to review or request changes to our content except for compliance reasons.
- We aim to make sure everything on our site is up-to-date and accurate as of the publishing date, but we cannot guarantee we haven't missed something. It's your responsibility to double-check all information before making any decision. If you spot something that looks wrong, please let us know.
VPS security can get a little tricky, for the simple reason that you’ll probably have to do most of the security work yourself. That’s the whole idea: a VPS is a virtual machine that, in most circumstances, gives you near-complete control over how it works. As a side effect, you're responsible for hardening the VPS (mostly).
To be clear, you won’t find a full server-hardening tutorial in this article. It’s too big a topic to cover every tool and trick here. Instead, I can offer a place to start: an overview of what you’ll need to learn to keep your website or app secure.
Who is responsible for VPS security?
Common VPS security risks
VPS security best practices
Managed vs. unmanaged VPS security
Bottom line: Is VPS hosting worth the security responsibility?
FAQs
Is VPS hosting secure?
VPS hosting can be secure, but how well it’s protected depends on both your hosting provider and how you configure and maintain the server. One major advantage over shared hosting: a VPS is isolated from other virtual private servers on the same physical server. Unlike shared hosting, that isolation reduces some risks from neighboring sites. This means that if someone else’s VPS gets compromised, yours is generally less likely to be affected, although isolation isn’t an absolute guarantee.
However, that isolation doesn’t do much to protect your VPS from being compromised directly. If you go with your typical unmanaged VPS hosting, then it’s all up to you. On the other hand, if you pay for managed hosting, a lot of the technical stuff like basic firewall configuration, software updates, and malware scanning may be handled for you, and you’ll mostly need to focus on hardening your actual website.
Who is responsible for VPS security?
You are responsible for VPS security, but so is your web hosting provider. Even on unmanaged hosting, the host is responsible for the security of their hardware, virtualization tech, and network. Most major hosts offer DDoS mitigation built into their network, and may also scan for malicious traffic as a matter of course. Better ones also offer built-in backup solutions. Protect your hosting provider account with multi-factor authentication (MFA), too, since access to that account may allow someone to manage or reset your VPS.
Everything that runs on top of that infrastructure is what you want to keep an eye on:
- OS and software configuration
- Security updates
- User accounts and permissions
- SSH access
- Firewall configuration
- Applications/websites
- User data
- Backups and recovery (on top of whatever your host provides)
Of course, this is all a generalization. The line between “your job” and “their job” will depend on the host in question, as well as whether the hosting package you get is managed or unmanaged.
Common VPS security risks
As a quick primer, here are the most common security issues you’ll run into. Below, we’ll cover how to mitigate them.
- Weak or compromised credentials: Use a password manager.
- Exposed root/administrator access: I’ll explain more about permissions below.
- Brute-force login attempts: Because they will just keep trying, and trying, and trying.
- Unnecessary open ports/services: You don’t want to have any more entry points to your server than necessary.
- Outdated operating systems and software: Outdated software is insecure software.
- Malware: For hosting servers, malware can be used to compromise the server itself and/or your site’s users.
- Misconfigured applications or servers: Yep, you can compromise your site if you use the wrong settings.
- DDoS attacks: Basically, a distributed denial-of-service attack happens when a gazillion machines connect to your site at once and clog the network.
- Missing or unusable backups: Yes, your backup system needs maintenance too.
VPS security best practices: How to secure your VPS
Don’t be too alarmed by the list above. You can resolve each of those issues, up to a point. Most digital security systems don’t aim to eliminate any possibility of attack. The only way to do that would be to take a sledgehammer to the server and walk away from it all. The goal is to make your server such a pain in the butt to attack that it’s not worth the bother.
By following this checklist and working together with your hosting provider, you can make that happen.
1. Keep your operating system and software updated
It’s a simple formula: the longer software exists, the more likely someone is to find holes in it. When people discover those security holes, they patch them. If you’re not running up-to-date versions of your software, then your site is vulnerable.
As a side note, remove any software you aren’t using, especially if it’s publicly accessible via the web. The less software you have running, the fewer ways people can attack your VPS.
2. Secure SSH access
SSH (Secure Shell) is the network protocol by which most VPS administrators access, manage, and configure their servers. That is, at least for those who use the terminal/command line for all of their server management needs.
SSH creates an encrypted connection between you and your server’s command line, letting you update and install software, manage files, and do anything else you want, if you know the right commands. But SSH alone isn’t perfect. If you use password-based login, an attacker could guess, steal, or brute-force the password. If you regularly log in as root and that account is compromised, attackers gain access to the entire server.
So instead of passwords, use SSH key pairs. The server checks that you have the private key matching a public key registered for your account. Also, double up on security by disabling SSH login with the root/admin account. Make sure key-based login works before disabling password or root login, so you don’t lock yourself out.
Lastly, protect your private keys. These are small text files on your local device that identify you to the remote server as an authorized user. Don’t share them, protect them with a passphrase, and, if possible, keep your personal/work computer’s drive encrypted.
3. Use least-privilege accounts
Even if you disable logging into the server as the root/admin user via SSH, you can still technically sign in as root from another account once you’re connected to the server. Avoid using root for routine work, as you could accidentally mess up the operating system and create vulnerabilities. Use elevated privileges only when you need them.
Use an account restricted to only the parts of the server you actually need to change. Likewise, most applications on your server (like WordPress) don’t need access to the whole server, just a small part of it.
4. Configure a firewall and close unused ports
Ports are virtual entryways to your server, each assigned a number. For example, ports 80 and 443 are used for exposing websites to the internet, and port 22 is typically used to connect to a server via SSH. A basic web server may not need more ports open than those, although other applications can require additional ports.
Every open port is a potential attack vector for your web host, so close the ones you aren’t using. Luckily, firewalls make this easy with firewall rules. Firewall rules determine which ports are open or closed, and can even be used to open some ports to a specific IP address, but not to others. You’ll need to look up how to do this with the particular firewall software you use, but firewall management is a skill you’ll be happy you learned.
5. Protect against brute-force attacks
A brute-force attack means someone is trying every password imaginable to access your server.
If you do use passwords to log in via SSH, or to log into your website’s control panel in WordPress (for instance), you’ll find attackers constantly trying to log in. Set up your server to temporarily block connections/login attempts from people who repeatedly fail to log in. WordPress has settings and plugins to make this easy.
For SSH login attempts, you can use software like Fail2Ban. Also enable MFA for your hosting control panel if your provider supports it.
6. Encrypt web traffic with HTTPS
HTTPS (Hypertext Transfer Protocol Secure) is the network protocol that lets users browse your website while encrypting all traffic between your site and its users. This means HTTPS helps prevent attackers from hijacking traffic to and from your website, injecting malware, or spying on private data. Thus, it is MUCH more secure than old-fashioned HTTP.
To make it work, you’ll need to get an SSL certificate. Luckily, that’s fairly easy, and usually free.
7. Monitor your VPS for suspicious activity
Once you have your other security configurations in place, keep everything secure. Malware scanners can help you find malicious programs that might make it onto your servers, although removing them may require separate tools or manual work. Network traffic scanners/web application firewalls can scan for unexpected changes in web traffic and alert you to security problems.
Also check your server’s/CMS’s logs for suspicious login attempts; monitoring tools can alert you if your CPU/RAM usage suddenly spikes, and so on. In short, security isn’t a one-time thing. It’s an all-the-time thing, and you need to keep an eye on your VPS.
8. Back up your VPS — and test recovery
Backups are a matter of security. Yes, they can get you back up and running after a crash, but sometimes you can’t just remove malware. You'll need to restore your server to a pre-compromise state and fix the security holes from there. Restoring a backup alone won’t fix the vulnerability that let the attack happen.
So yeah, back up your VPS often. Ideally, store backups far away from the data center where your VPS lives. Also, regularly test your recovery methods to make sure they work when you actually need to restore from a backup.
Managed vs. unmanaged VPS security
So, which is better, managed or unmanaged VPS? Well, as always, it depends. Unmanaged hosting gives you the most control, but you're responsible for almost the entire security stack. With total control comes total responsibility.
Managed VPS hosting can leave the host in charge of patching software, monitoring server resources, many basic configurations, backups, and more, depending on the host. (Check out our list of the best VPS hosts here, for examples.) However, that doesn’t mean you can relax and forget about security. As mentioned above, you’ll need to take steps to harden your website, at the very least. You’ll still need to keep an eye on things, and test your recovery systems, and so on.
Bottom line: Is VPS hosting worth the security responsibility?
Yes, VPS hosting is worth the extra security responsibility if you want more control over your website and you're comfortable managing your own server. A VPS being isolated from other virtual servers is a nice security feature. Or rather, it’s one less thing to worry about. But how that server is configured (and that will largely be up to you) has a much bigger impact on the overall security of your site.
So make sure you’ve got your admin access and account permissions squared away. Also make sure your software is up to date, you have recoverable backups, a well-configured firewall, and HTTPS set up properly. Yes, it’s a fair bit of work, but if you want full control over your site, it's worth it.
But if that all sounds like way too much work, managed VPS hosting can take a lot of the pain out of maintaining your site’s security. Managed hosting usually costs a bit more, but it may still be well worth it.
FAQs
Is a VPS more secure than shared hosting?
VPS hosting is isolated from other websites on the same physical server (unlike shared hosting), so vulnerabilities in other sites are unlikely to affect yours. However, the rest of the security equation is on you. If you don’t maintain or configure your server correctly, it can become vulnerable.
How do I make my VPS secure?
Here’s the short, short version of things to look at when securing a VPS: regular software updates, use SSH keys instead of passwords, don’t use the root/admin account when you don’t have to, configure your firewall, block any ports you aren’t using, always use HTTPS, monitor your server logs and scan for malware, and make regular backups.
Can a VPS be hacked?
Yes, a VPS can be hacked. Virtualization eliminates some vulnerabilities, but not all. Your server’s operating system, software, login and authentication mechanisms, and even the firewall can all create avenues of attack if they're not configured correctly.
Do I need a firewall on a VPS?
Yes, you need a firewall on a VPS, at the bare minimum. Firewalls limit access to ports, applications, and services that don’t need to be exposed to the internet, reducing the ways an attacker can get in. Always, always use a firewall on your VPS. It will save you pain.