How to disable ROOT account login under Linux

  

Root account is generally the account with the highest authority in Linux. If you attack a Linux server, you will generally guess the Root account password to attack. If you can crack the Root account, Generally speaking, you have control of a system.

So, we need to disable the root account remote login, create a new account for daily operations, if you need to log in with the root account, you can use

su root

Command to temporarily switch to the root user to use. The steps to disable the root account are as follows:

1. Add a new user first

useradd dyfcom

2. Set the newly added user password

passwd dyfcom< Br>

3. Use vi to edit the /etc/ssh/sshd_config file and find the following line

PermitRootLogin yes

Modify to

PermitRootLogin no

Then: wq exit and save

4. Restart ssh service

/etc/init.d/ssh restart

5. Try to log in again after logging out, If you can't log in, the configuration is successful

6. If you need root privileges in the future, you can execute it in the ssh client

su root

After entering the password, you can switch to root. User, then continue with the operation.

Tips:

There is a prerequisite for disabling Root users. It is best to configure an ftp server to upload files. Because the root account is disabled, most directories have no modification rights. If you upload it, you cannot use sftp to upload the management file.

Copyright © Windows knowledge All Rights Reserved