How to hide an account on KDE login screen?

I am running a CentOS 7 virtual machine on my laptop and I'm using KDE (version 4.14.8). That VM serves as an Ansible control tower, from which my Ansible descriptions are applied to the other (headless) VMs that I use on the same laptop.

My problem is that the graphical login screen shows my account as well as the account ansible. I thought system accounts would not show up in that list so I created ansible as a system account. But here is an excerpt from my /etc/passwd file:

hg:x:1002:1002:Mercurial SCM:/home/hg:/bin/bash
saned:x:986:980:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
backupscript:x:1003:1004:Data backup script:/home/backupscript:/sbin/nologin
ansible:x:985:979::/home/ansible:/bin/bash

As can be seen, hg is a user account, but it does not show up in the login screen, which means to me that the user account vs system account distinction is not the element that determines whether an account is shown in the login screen or not.

How can I hide an account on the login screen?


To hide the user account, you can add HideUsers=ansible in /etc/sddm.conf under the [User] session.


As of KDE 5, SDDM is the default login manager. Since you’re running KDE 4, I expect your system uses KDM instead. The KDM Handbook is no longer online, but the Wayback Machine has come to the rescue!

Chapter 4 says you can do what you need through System Settings → Login Manager, but it doesn’t give specifics:

Users

From here you can change the way users are represented in the login window.

Independently of the users you specify by name, you can use the System UIDs to specify a range of valid UIDs that are shown in the list. By default user id's under 1000, which are often system or daemon users, and user id's over 30000, are not shown.

Or Chapter 5 says you could edit kdmrc:

ShowUsers

This option controls which users will be shown in the user view (UserList) and/or offered for autocompletion (UserCompletion). If it is Selected, SelectedUsers contains the final list of users. If it is NotHidden, the initial user list contains all users found on the system. Users contained in HiddenUsers are removed from the list, just like all users with a UID greater than specified in MaxShowUID and users with a non-zero UID less than specified in MinShowUID. Items in SelectedUsers and HiddenUsers which are prefixed with @ represent all users in the user group named by that item. Finally, the user list will be sorted alphabetically, if SortUsers is enabled.

The default is “NotHidden”.

(A quick search suggests this file should be located at /etc/kde4/kdm/kdmrc.)


What’s interesting is that your /etc/passwd shows that ansible has a UID of 985… so it should already be hidden by default. Either of the above configuration options might let you see that this default has been overridden somehow.

If all else fails, you can manually change the user ansible to have some other UID and see if that fixes the problem.

First, find an unused UID. This command will list all the used ones:

$ awk -F: '$0=$3 "\t"$1' /etc/passwd | sort -g

Then, assuming you’ve found that 39001 is available, change the UID like so:

$ sudo usermod -u 39001 ansible

Note that any files that ansible owns will only have their ownership updated if they are in ansible’s home directory (/home/ansible according to your /etc/passwd). Anything else that ansible owns will need to be chown’d manually.