Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Ubuntu 12.04 server on which I've locked my only account, logged out, and now I cannot log in .

 jiechao@ubuntu-Jiechao:~$ sudo passwd -l jiechao
 passwd: password expiry information changed.
 jiechao@ubuntu-Jiechao:~$ logout
 Connection to 192.168.1.76 closed.

Now I cannot log in, as this is the only account on the server. How do I restore login access to this server?

share|improve this question
1  
How can you access the server ? If you have physical access boot it from a CD, mount read/write the root partition and them remove the !! for jiechao from the /etc/shadow file. –  golja Sep 23 '12 at 23:57
    
Hi, golja, thanks so much for the reply. I can boot it from CD, but how to change the /etc/shadow file? I don't know how to do that? Thanks –  Jiechao Li Sep 24 '12 at 0:01
add comment

2 Answers

Process to reset the password is in the Ubuntu Documentation: https://help.ubuntu.com/11.04/ubuntu-help/user-forgottenpassword.html

share|improve this answer
    
Thanks! RandomBit. My situation is the account is locked. I don't know whether it is the same with password reset. Actually, I did not changed the password. –  Jiechao Li Sep 24 '12 at 0:48
    
Root always exists. One hopes not disabled. Should be able to "sudo passwd" to make adjustments: help.ubuntu.com/11.04/serverguide/user-management.html (password expiration bits are further down the page) –  RandomBit Sep 24 '12 at 2:57
    
A password that was disabled by the 'passwd -l' syntax probably means that it has been prepended with a bang (!) character. You might simply be able to edit the /etc/shadow file and remove the leading '!' character. But at that point it's simply easier to do it properly and unlock the account with the passwd command. –  Magellan Sep 24 '12 at 3:41
add comment

"Physical" access is the only answer in situations where you have locked your only account.

Boot it up in single user mode. This will require 'rw' mode instead of 'ro' and specifying 'init=/bin/bash' while removing 'quiet' and 'splash'.

Note: Physical access and virtual environments such as VMware may mean a client console. Amazon instances may be much more difficult to impossible.

share|improve this answer
    
Hi, Adrian. Thanks for the answer I am using my own physical server. Not amazon service or VMware virtual machine. If I boot it up in single user mode, can I log in my locked account? or another account? –  Jiechao Li Sep 24 '12 at 0:13
    
If you're in single user mode, you can operate as if you were root. You can unlock accounts, fix filesystems, and many other tasks that require root. –  Magellan Sep 24 '12 at 0:25
    
Thanks, I will try that. –  Jiechao Li Sep 24 '12 at 0:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.