Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Change the SSH Port on Linux

Moving SSH off port 22 cuts bot noise. Do it carefully: open the new port in the firewall before you close the old one.

Steps

  1. Edit the sshd configuration:

    sudo nano /etc/ssh/sshd_config
  2. Set (or uncomment) a Port line with your chosen port, e.g. 2222. Save the file.

    Port 2222
  3. Open the new port in the firewall (UFW example) and allow traffic:

    sudo ufw allow 2222/tcp
    sudo ufw status
  4. Validate the config and reload sshd:

    sudo sshd -t
    sudo systemctl reload ssh
  5. In another terminal, test the new port before closing your current session:

    ssh -p 2222 user@YOUR_IP

Tips

  • Do not close the old session until the new-port login works.
  • Update Fail2Ban/iptables/UFW and your SSH client Host config.

ext step

eed a dedicated IP ready to harden SSH? Deploy on Xernode.

Related guides