Modify the ssh port and disable remote root login in Linux
Modify the ssh port and disable remote root login 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)
The procedure is as follows:
1. Edit the/etc/ssh/ssh_config file:
[Root @ db02 ~] # Cat/etc/ssh/ssh_config | grep Port
Port 9688
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:
# Vim/etc/ssh/sshd_config
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.