I created Ubuntu server in VirtualBox and created additional user. Than locked it with passwd -l user
. Then when I try to ssh that user, it keeps asking for password, but even if I input password, that was there before locking, it appears it isn't valid.
I'm new to Ubuntu so I'm a bit confused here.
Asked
Active
Viewed 953 times
1

Artyom Tsoy
- 111
- 4
2 Answers
3
A locked password doesn't mean the system won't ask for a password. It will ask for a password but it is impossible to give a correct password and login. That's how it works. If you unlock the password the old password will be reset.
From man passwd
:
-l, --lock
Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it
adds a ´!´ at the beginning of the password).
Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To
disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970).
-u, --unlock
Unlock the password of the named account. This option re-enables a password by changing the password back to its previous value (to the value
before using the -l option).
I'm not sure that when the manual says it adds a !
to the beginning of the password is correct, I think it adds that !
to the beginning of the hashed value in /etc/shadow
. Please correct me if I'm wrong.

falconer
- 15,026
- 3
- 48
- 68
0
Well in the end I figured out the source of the problem. Actually I had permission all messed up, because I created .ssh/authorized_keys from sudo and chmod 700 sat permissions to read and change permissions only for superuser...
Also I needed to ssh host machine to add it to list_of_known_hosts

Artyom Tsoy
- 111
- 4
ssh
and "login" technically you have to do that, yes. But as the manual says, you can use e.g. key-based authentication in thessh
and then it is not needed to have an unlocked account. (as the key based authentication doesn't care about the account password, just about the key.) You can also switch to that user account withsudo su USERNAME
if you need that kind of solution. – falconer Jan 24 '14 at 10:57/etc/ssh/sshd_config
– falconer Jan 24 '14 at 11:26