SSH error: Permission denied, please try again

You've locked the account.

From the manpage of usermod(8):

-L, --lock
           Lock a user's password. This puts a '!' in front of the encrypted password,
           effectively disabling the password.

Now look at your shadow line:

ubuntu:!$6$rWDSG...HSi1:15347:0:99999:7:::

Unlock it:

usermod -U ubuntu

Important note! If this user is preinstalled on the system it may be locked for a reason (security reasons), but I cannot decide that for you since this isn't a regular Ubuntu install apparently.


If the above makes you feel uncomfortable, you could create a separate user:

sudo adduser username

and answer the questions. You should be able to login just fine. Also make it able to become root (use sudo) by adding it to the sudo group:

sudo adduser username sudo

In case you need to switch to the ubuntu user on the command line, you'll have to use your elevated privileges, because you can't provide credentials for the same reason as why you can't log in using SSH. Now, log in using SSH as username, and run this to become ubuntu:

sudo su -l ubuntu

For security reasons I would not advise to use root to log in directly.


This is not exact answer for this question. But In my case, there was redundant lines. (there were same line twice)

PermitRootLogin yes

and also

AllowUsers otheruser

You should add 'root' user to this line or comment this line.

And restart ssh service sshd restart


I have the same problem and it take for me many hours .

However, i note that it is a wrong password because of differrence between keyboard layout of server snd client :

In Server, i thought that i set password : WEwd@ds And , i note that @ is " in the server keyboard layout.

So the right password is : WEwd"ds


Thus, you need to check :

Server keyboard layout [vs] Workstation keyboard layout