A guide for modifying the default SSH port on Vultr Compute instances to improve security against automated attacks
Changing the default SSH port (22) enhances security by reducing automated attacks. Follow the steps below to safely change the SSH port on your Vultr Compute instance:
SSH into your Vultr instance.
Open the SSH daemon config file.
$ sudo nano /etc/ssh/sshd_config
Locate the following line:
#Port 22
Uncomment it and replace 22
with your desired port number (e.g., 2222
):
Port 2222
Use a port between 1024
and 60000
to avoid conflicts.
Allow the new port in the firewall.
$ sudo ufw allow 2222/tcp
Restart the SSH service to apply the changes.
$ sudo systemctl restart sshd
To SSH into your instance now you have to define the port as well.
$ ssh username@your_instance_ip -p 2222
Once verified, you can optionally remove access to port 22
:
$ sudo ufw delete allow 22/tcp
The above steps are demonstrated on an Ubuntu instance. If you're using a different Linux distribution (like CentOS, AlmaLinux, or FreeBSD), refer to your system's specific documentation.