Change Default SSH Port to Prevent Attacks

Change Default SSH Port to Prevent Attacks

By default, SSH runs on port 22, which is the primary target for automated brute-force attacks. Changing this port adds an extra layer of protection against malicious attempts.

Step 1: Open SSH Configuration File

sudo nano /etc/ssh/sshd_config

Step 2: Change SSH Port

Find the line:

#Port 22

Uncomment and change it to another port, e.g.:

Port 2222

Step 3: Adjust Firewall Rules

Allow the new port in your firewall:

sudo ufw allow 2222/tcp

Step 4: Restart SSH

sudo systemctl restart ssh

✅ From now on, connect to your server using the new port:

ssh -p 2222 user@your-server-ip

  • VPS Security, SSH Port, Server Hardening, Brute Force Protection
  • 0 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Gerelateerde artikelen

How to Set Up a Firewall (UFW) on Your VPS

How to Secure Your VPS with a Firewall A firewall is essential for protecting your VPS from...

Securing SSH Access on Your VPS

Securing SSH Access on Your VPS SSH is the primary way to access your VPS. By hardening SSH,...

Protecting Your VPS with Fail2Ban

Protecting Your VPS with Fail2Ban Fail2Ban helps protect your VPS from brute-force attacks by...

Securing Your VPS with UFW Firewall

Securing Your VPS with UFW Firewall UFW (Uncomplicated Firewall) helps you manage firewall...

Disable Root Login for Better VPS Security

Disable Root Login for Better VPS Security Allowing direct root login via SSH is risky and...