Logging in as the root user has many drawbacks due to its excessive privileges; a minor mistake, such as deleting the wrong file, can lead to severe consequences. Disabling direct root login is, in a sense, also beneficial for server security.
For security reasons, it is recommended to first create a standard user and then switch to the root user using the su command.
1. Create a standard user with the username yunwei123.com
# useradd yunwei123.com
2. Set a password for the yunwei123.com user
# passwd yunwei123.com Changing password for user yunwei123.com. New password: Retype new password: passwd: all authentication tokens updated successfully.
3. Modify the sshd_config file as follows
# vi /etc/ssh/sshd_config #PermitRootLogin yes Change to the following: PermitRootLogin no
4. Restart the SSH service
# /etc/init.d/sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ]
To log in, use the standard user created above. If you need to use the root user, switch to it using the su command.