Changing the SSH port & disabling root login is something that everyone should do as it adds an extra level of protection to your server.
Login to your server using root
Edit /etc/sshd/sshd_config
At the top of the file, you will see something similar to:
Port 22
Protocol 2, 1
Change the Protocol line to 2
The port option, it really is up to you what port you use. Just make sure with netstat that it is not being used for anything else. Some common secondary SSH ports are 1024 or 2222.
Scroll down and disable direct root login
PermitRootLogin no
If there is a # in front of the line, make sure to remove it. Now just save the file and exit your editor.
Restart SSH:
/etc/init.d/sshd restart
That’s it, try opening a new session without closing the existing one, just in case you need to roolback the changes or edit anything and check ifi t’s done.
Login to your server using root
Edit /etc/sshd/sshd_config
At the top of the file, you will see something similar to:
Port 22
Protocol 2, 1
Change the Protocol line to 2
The port option, it really is up to you what port you use. Just make sure with netstat that it is not being used for anything else. Some common secondary SSH ports are 1024 or 2222.
Scroll down and disable direct root login
PermitRootLogin no
If there is a # in front of the line, make sure to remove it. Now just save the file and exit your editor.
Restart SSH:
/etc/init.d/sshd restart
That’s it, try opening a new session without closing the existing one, just in case you need to roolback the changes or edit anything and check ifi t’s done.