How to Change Your Default SSH Port for Better Server Security
By default, your server allows SSH connections on port 22 - which is widely known and often targeted by attackers. To add an extra layer of protection to your cloud server at Vivint Host, it’s highly recommended to change this default port to a custom one. Here's how to do it the right way.
Step 1: Open the New SSH Port in Web Host Manager
Before making any changes to your server's SSH configuration, you must open the new port in your firewall to avoid locking yourself out.
- Log in to Web Host Manager.
- Navigate to "Plugins" > "ConfigServer Security & Firewall".
- Click on "Firewall Configuration".
- Find the field labeled TCP_IN.
- Add your preferred port number (e.g., 5622) to this list.
- Scroll down and click "Change" to save.
- Restart CSF by clicking "Restart csf+lfd".
Step 2: Update the SSH Configuration on Your Server
Next, you need to edit your SSH configuration file to switch from the default port to your new one.
- Use your terminal (on Mac: Applications > Utilities > Terminal) and connect to your server:
ssh [email protected] (replace with your server IP)
Replace your_server_ip with your actual server IP address.
- After logging in, locate the SSH config file:
locate sshd_config
Typically, the file is located at /etc/ssh/sshd_config.
- Open the file with a text editor:
nano /etc/ssh/sshd_config
Uncomment where it says Port 22 and change this to 5622. Command + X (on a Mac) to exit, type Y (for yes) to save, and then exit.
You then need to start SSH inside of Web Host Manager:
- Login to Web Host Manager
- Click on SSH Server (Open SSH) under Restart Services
Congratulations – your SSH port has now been changed to 5622. It’s important to note, the next time you SSH into your server, you need to us -p to define the port:
ssh -p 5522 [email protected] (replace with your server IP)
We're committed to helping you secure your cloud hosting environment. Need assistance? Our 24/7 expert support is always here for you!
