About solving the problem that root user ssh remote login is not allowed in Linux (ubuntu)

When we log in to ssh in ubuntu, the following problems will occur:

This is because the system prohibits root users from logging in to ssh by default. At this time, we can solve it like this:

1. First, press Ctrl+C to exit the password input interface

2. Then enter: su - ( must be su -, not su )

3. Edit the sshd_config file, we enter: vi /etc/ssh/sshd_config

The following file editing interface appears:

We drag down and find #Authentication

By default, root is not allowed to log in to SSH, so we need to make corresponding settings and modify it as shown in the following figure (a few blank lines are made by myself, but don't; PermitRootLogin without-password was deleted for me).

Then we need to save and exit, press ctrl+c, then enter: wq. At this point, root is allowed to log in to ssh.

# Authentication:
LoginGraceTime 120
#PermitRootLogin without-password
PermitRootLogin yes
StrictModes yes


 Extension: Options for PermitRootLogin

sshd_config is the configuration file of sshd, which PermitRootLogincan limit the login method of the root user through ssh , such as allowing only key login, open login, forbidden login, and forbidden password login, as shown in the following figure

In the above options, the parameters yes and no are only very rude to allow or prohibit the root user from logging in. without-passwordOn the basis of yes, the root user is prohibited from logging in with a password. 

5. Then we need to restart the ssh service, enter: /etc/init.d/ssh restart

6. Finally, test whether the ssh connection is successful. Enter: ssh localhost, enter the password, and then enter the corresponding root password, and then press Enter. If the following interface appears, it means that the login is successful, and you're done!

Guess you like

Origin blog.csdn.net/hml111666/article/details/123422039