Change the SSH Port on Dedicated Server or VPS

Security for your dedicated server and vps are incredibly important. All servers are secured before going online for the user, but there are always extra steps you can take to improve your security. Most linux based dedicated servers and vps connect through SSH. By default the SSH port is set to 22, so this already gives hackers or bots that want to access your server the port from which they can start poking at to find a vulnerability. So changing the default SSH port is recommended. You can do this easily by following these steps:

 

1.- Find the SSH configuration file at /etc/ssh/sshd_config

Note: After updating SSH ports, be sure to add the port number to the firewall; otherwise, users could be locked out of the server.

2.- Change Specific Parameters within sshd_config

  1. Log into your server as the root user.
  2. Uncomment the desired line by removing the number-sign (#) and changing the value for the line.For example, the default SSH port appears in a line like this:#Port 22

    To change the SSH port to 456, you will need to make the line appear like this:

    Port 456

3.- Update IPTables and Firewall

After you are finished configuring SSH, you will need to add the port to iptables as well as your installed firewall.

To update iptables, please enter the following in SSH:

iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 456 -j ACCEPT

When using the command above, be sure to substitute 456 with the actual port number you are adding.

 

4.- Reset SSH Daemon

After making the necessary changes to iptables and your computer’s firewall, you will need to restart the SSH daemon. You can do so by issuing the following command:

/etc/init.d/sshd restart

Log out of your server and log in again using the proper user, IP address and port number you specified in sshd_config.

Now that you’ve changed your SSH default port your server’s security is much better. Combine this with other security tips to completely overhaul your security, making it that much more difficult for anybody or anything trying to get your data. You can also rest assured us at Webline-Services do out best to secure your server as well even before issuing it to you.

Change Your Default SSH Port
Tagged on:                 

Enjoy this blog? Please spread the word :)