Let's say I create a user named "bogus" using the adduser command. How can I make sure this user will NOT be a viable login option, without disabling the account. In short, I want the account to be accessible via su - bogus, but I do not want it to be accessible via a regular login prompt.

Searching around, it seems I need to disable that user's password, but doing passwd -d bogus didn't help. In fact, it made things worse, because I could now login to bogus without even typing a password.

Is there a way to disable regular logins for a given a account?

Note: Just to be clear, I know how to remove a user from the menu options of graphical login screens such as gdm, but these methods simply hide the account without actually disabling login. I'm looking for a way to disable regular login completely, text-mode included.

link|improve this question

75% accept rate
1  
Your -d is the flag to delete the password. That is different from disabling it (refereed to as locking, see Chad's answer). – Caleb Aug 24 '11 at 20:59
feedback

2 Answers

up vote 18 down vote accepted

passwd -l

is what you want.

That will lock the user account. But you'll still be able to

su - user

but you'll have to su - user as root.

Alternatively, you can accomplish the same thing by prepending a ! to the user's password in /etc/shadow (this is all passwd -l does behind the scenes). passwd -u will undo it.

link|improve this answer
feedback

Set /bin/false as a shell in /etc/passwd

link|improve this answer
5  
When one sets the shell to /bin/false, one prevents using su to act as that user. Additionally, using /bin/false produces no error nor other hint of what just went wrong -- in cases where one does want to prevent even su from being used to get a shell as that user, the shell should be changed to /sbin/nologin which does produce an error. – HedgeMage Aug 24 '11 at 16:22
feedback

Your Answer

 
or
required, but never shown

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