Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Securing a Fresh Linux VPS: SSH Keys, UFW, and Fail2ban in 20 Minutes

Introduction to Securing Your Linux VPS Congratulations on your new Linux VPS! Whether you're hosting a website, setting up a development environment, or experimenting with server management, securing your server should be your top priority. In this guide, we'll explore how to enhance the security of your VPS by setting up SSH keys, configuring a firewall with UFW, and using Fail2ban to protect…

Welcome to securing your new Linux VPS! This guide will walk you through enhancing your server's security with three key steps - utilizing SSH keys, configuring a firewall with UFW, and employing Fail2ban against unauthorized access. Within just 20 minutes, you'll establish a robust foundation for server protection. Establishing SSH Key Authentication Enhances security by opting for SSH key authentication over passwords.

SSH keys provide robust protection against brute-force attacks on login credentials. Here's how to configure it: Generate an SSH key pair on your local machine via a terminal by executing ssh-keygen. Follow the prompts to create the key pair, which will be stored in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub by default. Transfer the public key to your VPS using the command ssh-copy-id user@your_vps_ip.

You'll be prompted to enter your user password on the VPS. Afterward, disable password authentication by editing the SSH configuration file on the VPS with sudo nano /etc/ssh/sshd_config. Locate the PasswordAuthentication line and change its value to no. Finally, restart the SSH service with sudo systemctl restart ssh. A comprehensive guide on setting up SSH key authentication is also available for further clarification.

Activating UFW for Firewall Protection UFW, an uncomplicated firewall, simplifies iptables management for firewall rules. To enable protection, you must first install UFW and configure necessary rules: Install UFW with sudo apt install ufw for Debian-based systems or sudo yum install ufw for Red Hat-based systems. Allow SSH connections by running sudo ufw allow ssh.

Activate the firewall using sudo ufw enable. Check the current status and applied rules with sudo ufw status. Customize additional rules based on the services you intend to run on your VPS. For instance, hosting a web server would require using sudo ufw allow http and sudo ufw allow https. Implementing Fail2ban for Intrusion Prevention Protects your server from brute-force attacks by monitoring log files and banning IPs with suspicious activities.

To set up Fail2ban: Install Fail2ban on Debian-based systems using sudo apt install fail2ban, or on Red Hat-based systems with sudo yum install fail2ban after enabling the EPEL repository first. Configure Fail2ban by creating a local configuration file from the default by copying /etc/fail2ban/jail.conf to /etc/fail2ban/jail.local.

Edit jail.local to specify the services you wish to safeguard, ensuring SSH is included. Start Fail2ban service with sudo systemctl start fail2ban, and enable it to start on boot with sudo systemctl enable fail2ban. Monitor its activity via sudo fail2ban-client status and identify any banned IPs. To conclude, by applying these security measures, you've safeguarded your Linux VPS effectively.

Remember, security necessitates continuous vigilance and staying updated about potential threats and updates. If you're prepared to implement these practices on your server, consider purchasing Linux VPS to embark on your journey of secure server management.

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

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Ransomware compromised server and backups of accounting office in 2018

Invasion during the weekend An accounting office was hit by a ransomware attack in 2018. On Monday, employees found the files encrypted and a demand for R$ 20 thousand in Bitcoin to regain access.

  • Accounting office in Brazil hit by ransomware attack in 2018
  • Hackers exploited exposed DVR port to gain network access
  • Data recovered for 60%-70% after partial recovery

Audit EPUB Cover Metadata With a Small Python Script

When an EPUB shows its cover in Apple Books or Calibre but arrives on a Kindle as a grey tile, the image is usually fine.

  • EPUB cover metadata can be audited with a small Python script
  • Script reads container.xml, finds OPF package file
  • Ensures all metadata declarations point to correct cover image

Why Your Headless Browser Can't Scrape Everything

Originally published on my blog — read it there with the full context, code and updates . I hit the same wall a few weeks apart, on two different second-hand marketplaces, and the contrast taught me…

  • Headless browsers scrape Carousell's freshly-listed products easily.
  • Goofish blocks headless browsers, requiring authentication and anti-bot checks.
  • Data source determines scraping approach: server-rendered vs asynchronous requests.

I built KaggleFleet to simplify collaborative Kaggle GPU workflows

Working on ML experiments with multiple collaborators often means dealing with multiple notebook runs, Kaggle accounts, and output files.

  • KaggleFleet simplifies collaborative Kaggle GPU workflows
  • Local-first notebook workflow retains notebooks in project
  • Multiple accounts configured independently via browser auth

More from Sunday 22 November →