Question

How to Secure a DigitalOcean Droplet Against Common Attacks?

Hi,

I’m concerned about the security of my Droplet, especially with recent reports of increased cyber threats. What are the most important steps I should take to secure my Droplet against common attacks like brute force, DDoS, and malware?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
September 3, 2024
Accepted Answer

Hey there,

DigitalOcean automatically provides DDoS protection out of the box:

In addition to that DDoS protection that you get for free, you can add more layers by using a CDN like Cloudflare to help mitigate large-scale DDoS attacks.

Besides the DDoS protection, one of the first things you should do is set up SSH key authentication and disable password login. This makes it much harder for attackers to gain access to your Droplet through brute force attacks.

Next, DigitalOcean provides a cloud firewall that you can use to control access to your Droplet. Set up rules to allow only the necessary traffic (like SSH, HTTP/HTTPS) and block everything else.

Then, always keep your operating system and software packages up to date. Regular updates include security patches that protect against vulnerabilities.

  • How to Update Your Droplet: Use sudo apt update && sudo apt upgrade (for Ubuntu) or equivalent commands for your OS.

You can also use Fail2Ban which is a tool that helps protect your server from brute force attacks. It monitors your logs for suspicious activity and automatically bans IPs that show malicious signs, like too many failed login attempts.

In case of a successful attack, having a recent backup can save you a lot of trouble. Enable automated backups or use a service like SnapShooter to regularly back up your Droplet.

Always monitor your Droplet’s activity using monitoring tools like DigitalOcean Monitoring or third-party services. If you detect anything unusual, investigate immediately.

  • CloudFlare DDoS Protection Script:

    A bash script that automatically manages CloudFlare’s DDoS protection based on your server’s CPU load. When CPU usage exceeds normal thresholds, the script automatically enables CloudFlare’s “Under Attack Mode” and disables it once the load returns to normal. Perfect companion to DigitalOcean’s built-in DDoS protection for an additional layer of security.

    This script is particularly useful when:

    • You want automated DDoS protection management
    • You need to respond quickly to sudden traffic spikes
    • You want to combine DigitalOcean’s DDoS protection with CloudFlare’s security features

You can also learn more about security here:

https://www.digitalocean.com/security

Hope that this helps and stay safe out there!

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.