7

Well I know the question is weird, but i have a user "Bob" and I want only bob's account to be stuck in infinite login loop. Please note I don't want to get out of a login loop..I want this particular user to be stuck in infinite login loop.

How do I do this?

4
  • 3
    The OP only wanted the user Bob to go into infinite login loop. It is obvious he is concerned with GUI login screen, thus changing permissions/ownership of .Xauthority is enough Apr 13, 2015 at 19:26
  • 1
    Why would you do such a thing?
    – Elder Geek
    Apr 13, 2015 at 20:37
  • 1
    Please review ubuntu.com/about/about-ubuntu/conduct
    – Elder Geek
    Apr 14, 2015 at 0:38
  • 5
    I think this should a stack exchange site "How to mess with your coworkers" Apr 14, 2015 at 1:13

4 Answers 4

12

To address bodhi's comment that the user can login through other means, open the file /etc/security/limits.conf and at the bottom add the following line

username hard maxlogins 0

The user will be able to login in tty but will be kicked out immediatelly, and lightdm (or any other login manager for that matter) will do the same. For good measure I would use this together with chowning .Xauthority

6

Change the shell for Bob:

sudo chsh -s /bin/false Bob
3
  • This is the normal way. Due to the way xlogin works it still invokes the shell so it still fails out.
    – Joshua
    Apr 13, 2015 at 21:23
  • 2
    Please read this: SSH Security and You - /bin/false is not security Apr 14, 2015 at 12:16
  • 1
    What does security have to do with this question, which the OP has asked?
    – A.B.
    Apr 14, 2015 at 12:17
4

Open Terminal (Press Ctrl+Alt+T). Execute this command in terminal.

chown -R root:root /home/Bob/.Xauthority

This command with change ownership of .Xauthority directory of Bob user to root user thus not allowing Bob to login.

14
  • 13
    The user can still log in via other means, ssh or kerberos to name a few. Set the users shell to /bin/false , that will prevent login.
    – Panther
    Apr 13, 2015 at 19:06
  • 1
    @bodhi.zazen I've addressed that Apr 13, 2015 at 20:02
  • 7
    Restart your system? This isn't Windows were talking about! Apr 13, 2015 at 23:51
  • 6
    Reboot your system? This isn't Windows we're talking about! Apr 14, 2015 at 4:43
  • 3
    You already got the comments explaining the downvotes. One issue, the superfluous reboot, has been fixed by A.B.'s edit. (Unlike Windows users, many Linux users care about uptime. Unnecessary reboots are considered bad advice — and reboots are rarely necessary.) The second issue, that this answer only prevents X session logins, in an easily circumventable way, is a fatal flaw with this answer. The user can still log in through a text console (Ctrl-Alt-F1). Once logged in, Bob can rm .Xauthority, even though the file is owned by root. Then your entire solution is defeated. Apr 14, 2015 at 9:04
-1

If the purpose is to prevent login of the user Bob, I suggest you can also lock the user password and expire his account using:

passwd -l bob
usermod --expiredate 1 bob

This blocks also ssh login with keys. There is more info in how to enable or disable an user question.

You must log in to answer this question.