Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I switch user without password in ubuntu server 11.1 ?

in CentOS

passwd -d -u username

but Ubuntu 11.10 not work

share|improve this question
Why do you want to do this? ssh keys or sudo might be better options? – ijk Mar 17 '12 at 16:17
up vote 4 down vote accepted
  • I would seriously think before "logging in as some other user but myself". There are laws and privacy policies that normally forbid such behaviour without user's approval.
  • Please use good passwords. Good passwords take 3-5 seconds of your time and give you tons of security layers.
  • Avoid these solutions for servers that are connected to the Internet.
  • Please make sure your user does not have an encrypted home or encrypted private directories. The user can lose their data if they don't know their old password.

Solution 1

sudo passwd myotheruser

Use "x" as password. Then login as myotheruser with password "x":

sudo login myotheruser

Solution 2

There is another solution, using pam.d without password:

Namely, you have to:

sudo addgroup nopasswdlogin
sudo adduser myotheruser nopasswdlogin

Then change the file /etc/pam.d/login and place this somewhere before "@include common-auth" line:

auth sufficient user ingroup nopasswdlogin

Again, please use good passwords, you don't want to be featured on websites such as :)

share|improve this answer
It is probably worth noting that you shouldn't ever use a password change method that doesn't request the old password if you're also making use of encrypted home or private folders. When both passwords are provided, the filesystem key can be re-encrypted seemlessly. With an administrative password reset, this can't be done. – James Henstridge Feb 8 '12 at 10:03
@JamesHenstridge Very nice comment, but is it possible to do what you mention as an administrator? Perhaps to set the current password as expired? Or do you have to login as the user and do passwd user? – medigeek Feb 8 '12 at 18:27
The key used to unlock the home directory is encrypted with the users password. Without the old password, there is no way to recover that key, whether you're a normal user or the administrator of the system. It is still possible to recover the key after an administrative password change, but only if you know the user's old password. – James Henstridge Feb 9 '12 at 0:56

Your Answer


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.