Solve the problem that the root account of Ubuntu cannot log in to SSH - Permission denied, please try again.

Sometimes, when we log in to SSH, the following problems will occur:

At this time, it is because the system defaults to prohibit the root user from logging in to ssh. At this time, we can solve it like this:

First, Ctrl+C exits the password input interface:

Then type: su -

Tips: It must be su -, not su

Then the following interface appears:

Then, we edit the sshd_config file, we enter: vi /etc/ssh/sshd_config

The following file editing interface appears:

We drag down and find the following lines:

We can see that these lines do not allow root to log in to SSH by default, so we need to set the corresponding settings and replace them with the following:

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

OK, at this point, root is allowed to log in to ssh, and the change is as shown below:

Then we need to save and exit, press Esc, and type: wq! , which successfully saves and exits.

Next, we need to restart the ssh service, we type: /etc/init.d/ssh restart

After execution it looks like this:

Ok, then let's test whether ssh can connect, we enter: ssh localhost

We can see that after execution, we will be asked to enter the password, then we enter the corresponding root password, and then press Enter, the following interface will appear:

We can see, successful login, ok, done.

 

http://blog.csdn.net/weiwei_pig/article/details/50954334

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326232413&siteId=291194637