Managing Autologin

franton
Valued Contributor III

Hi all,

Wanted to quickly share this with you all. I've found that a few computers on our estate had been set by people unknown to autologin which is a big security nightmare! A little digging, an extension attribute, a smart group and a script have solved this nicely. None of this is too complicated, but it is effective.

Let's start with the extension attribute. Paste in the following code:

#!/bin/bash

# Script to detect if autologin has been set on a target mac.

# Author      : r.purves@arts.ac.uk
# Version 1.0 : 30-01-2013 - Initial Version

# Check if /etc/kcpassword exists and report findings

if [ -f /etc/kcpassword ];
then
   echo "<result>Enabled</result>"
else
   echo "<result>Disabled</result>"
fi

# All done!

exit 0

Next, set up a new smart group. All it has to do is look for this setting as "Enabled".

You'll need the following script to do the work:

#!/bin/bash

# Script to disable auto login on a target mac.

# Author      : r.purves@arts.ac.uk
# Version 1.0 : 30-01-2013 - Initial Version

# Delete the section of the loginwindow plist that enables it

defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser

# Delete the file containing the cached password

rm /etc/kcpassword

# All done!

exit 0

Now you just need a policy to tie all this together. I've ours set to run on the "every15" trigger and set to "Ongoing". The policy is scoped to the smart group you set up earlier, it runs the script above and updates the inventory.

That'll stop them tinkering!

2 REPLIES 2

mm2270
Legendary Contributor III

Nice, but I need to ask, why not just use an MCX setting to completely lock users out of the setting altogether in System Preferences? Or, have you done that already and someone circumvented it? Our users are admins and we've locked them out of that setting.

franton
Valued Contributor III

We've had issues with local MCX not applying properly. This way also allows us to see via smart group inventory which of our departments are being continually misused in this way.