Changing your SSH port can help prevent security issues. In this guide, you’ll learn how to can change the SSH port on CoreOS.
We can change the SSH port by modifying settings in the /usr/lib/systemd/system/sshd.socket file. Open this file with a text editor:
Find the ListenStream option and change the port to your new desired SSH port. Save the file.
If you are running a firewall on your CoreOS server, remember to allow yourself access with the new SSH port.
Restart the SSH daemon using systemctl:
systemctl restart sshd.socket
The SSH server has been restarted and is now listening on the new port.
If you can no longer log into SSH, use the online console at My OneHost Cloud to troubleshoot the issue. As previously mentioned, this can happen if you have forgotten to open the new SSH port in the system firewall.
In addition to changing the SSH port, disabling access for the root user over SSH is also a good security measure.
Open the /etc/ssh/sshd_config config file with an editor:
Change the value of PermitRootLogin from yes to no. Save the file
Restart the SSH daemon again with systemctl:
SSH attempts as the root user to your server will now be denied.
Powered by BetterDocs