Change the ssh port and disable root remote logon in Linux
We all know that the default ssh port number is 22. To change the port number to 9688, You need to edit the/etc/ssh/ssh_config and/etc/ssh/sshd_config files;
To disable remote root logon, edit/etc/ssh/sshd_config. (Some Linux directories may be/etc/sshd. Please modify them as needed)
Refer to: Linux to modify SSH ports and disable root remote login settings
The procedure is as follows:
1. Edit the/etc/ssh/ssh_config file:
Root@www.bkjia.com ~ # Cat/etc/ssh/ssh_config | grep Port
Remove the comment symbol "#" before the commented-out Port 22, and change 22 to 9688 above. Save and exit.
2. Edit the/etc/ssh/sshd_config file:
Find PermitRootLogin and change "yes" to "no", so that the root user cannot log on remotely. Save and exit.
3. Restart ssh:
#/Etc/init. d/ssh restart
In this way, the ssh port number is successfully changed and root remote logon is disabled. It is worth mentioning that if your Linu x contains only root users, you must create a new user before disabling root remote logon, otherwise, ssh cannot be used to remotely log on to the server!
The content in this article is tested in Ubuntu. commands in other Linux systems are similar.
This article permanently updates the link address: