Top 10 Ports to Secure on VPS CentOS 8 to Prevent Cyber Attacks
In today’s complex network environment, secure ports on a VPS CentOS 8 is crucial to minimize the risk of attacks. Below is a list of the Top 10 Ports to Secure on VPS CentOS 8 to Prevent Cyber Attacks.
-
Port 22 (SSH)
-
Purpose: Remote connection via SSH to manage the VPS.
-
Risk: Often targeted by hackers with brute force attacks to guess passwords.
-
How to Secure:
Change the SSH Port:
- Open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
- Find the line #Port 22, remove the #, and replace it with another port number, e.g.,:
Port 2222
- Restart the SSH service:
sudo systemctl restart sshd
- Update the firewall to open the new port:
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --remove-port=22/tcp
sudo firewall-cmd --reload
Install Fail2Ban:
sudo dnf install fail2ban
- Configure Fail2Ban to protect SSH by creating or editing the /etc/fail2ban/jail.local file.
- Restart Fail2Ban:
sudo systemctl restart fail2ban
Articles that may interest you: How to install and configure Fail2ban on Ubuntu 20.04 VPS
-
Port 80 (HTTP)
-
Purpose: Serving websites via the HTTP protocol.
-
Risk: Vulnerable to HTTP injection attacks or DDoS attacks.
-
How to Secure:
Switch to HTTPS: Install SSL/TLS using Certbot:
sudo dnf install certbot python3-certbot-nginx
sudo certbot --nginx
Leverage Cloudflare: Use Cloudflare to mitigate DDoS attacks.
-
Port 443 (HTTPS)
-
Purpose: HTTPS ensures secure encrypted data transmission.
-
Risk: Resource exploitation through SSL stripping or DDoS attacks.
-
How to Secure:
- Deploy a trusted SSL/TLS certificate.
- Use a Web Application Firewall (WAF) to protect the application layer.
-
Port 3306 (MySQL)
-
Purpose: Access to the MySQL database.
-
Risk: Exploited through SQL injection or brute force attacks.
-
How to Secure:
Allow connections only from localhost: Edit /etc/my.cnf and add the line:
bind-address = 127.0.0.1
Restart MySQL:
sudo systemctl restart mysqld
Use strong passwords and enable SSL for connections.
-
Port 3389 (RDP)
-
Purpose: Remote Desktop Protocol for Windows Servers.
-
Risk: Susceptible to brute force or man-in-the-middle attacks.
-
How to Secure:
Change the default port:
sudo firewall-cmd --permanent --add-port=3390/tcp
sudo firewall-cmd --reload
Implement a VPN to secure remote sessions.
-
Port 21 (FTP)
-
Purpose: File transfer via FTP protocol.
-
Risk: Vulnerable to eavesdropping due to lack of encryption.
-
How to Secure: Use SFTP (via port 22) or FTPS instead of plain FTP.
-
Port 25 (SMTP)
-
Purpose: Sending emails via the SMTP protocol.
-
Risk: Exploited for spamming or relay attacks.
-
How to Secure:
- Restrict SMTP access to authorized IPs.
- Configure SPF, DKIM, and DMARC to authenticate emails.
-
Port 53 (DNS)
-
Purpose: Resolving domain names to IP addresses.
-
Risk: Exploited in DNS amplification attacks.
-
How to Secure:
- Disable DNS recursion on unnecessary servers.
-
Port 6379 (Redis)
-
Purpose: Connecting to the Redis database.
-
Risk: Exposed to unauthorized access due to the lack of authentication by default.
-
How to Secure:
Set a password in /etc/redis/redis.conf:
requirepass StrongPassword
Restrict access to localhost:
bind 127.0.0.1
Restart Redis:
sudo systemctl restart redis
-
Port 123 (NTP)
-
Purpose: Synchronizing time via Network Time Protocol (NTP).
-
Risk: Exploited in NTP amplification attacks.
-
How to Secure:
Disable the monlist feature: Edit /etc/ntp.conf and add the line:
disable monitor
Restart the NTP service:
sudo systemctl restart ntpd
Conclusion
Secure ports on VPS CentOS 8 is essential to prevent cyber attacks. Use firewalls, authentication mechanisms, and tools like Fail2Ban to enhance the security of your VPS CentOS 8.
Contact us today for expert advice and exclusive deals on VPS solutions.