Can autologin be set up from the command line? how?
I am attempting to automate the setup of a vsts 'build agent' for mac, as documented here: https://www.visualstudio.com/en-us/docs/build/admin/agents/v2-osx
One recommended step, that is definitely useful in our usecase is to configure autologin (and lock), and the step links to this guide:
https://www.engadget.com/2011/03/07/terminally-geeky-use-automatic-login-more-securely/
I've found many references to the system preferences GUI approach, which did work when I tested by hand, but few to the command line approach, which is what I would like to do for my script. Some command line approaches are outdated, with references to 'systemsetup' which is no longer available. We are currently on 10.11, and planning to move to 10.12 at some point, so any approach for these systems would be appreciated.
I have found reference to the 'autoLoginUser' plist setting, which I have tested. It can be set with commands like:
sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser "buildagent"
This value IS set when the preferences are set, but it is not sufficient by itself.
Can this be done entirely from the command line, such as via a script? if so, how?
You need to create the /etc/kcpassword
file.
There is a small utility that will do this for you: https://github.com/xfreebird/kcpassword.
This is just a simple wrapper around this script: https://github.com/timsutton/osx-vm-templates/blob/master/scripts/support/set_kcpassword.py
which is itself a python translation of the original perl script from Gavin Brock: http://www.brock-family.org/gavin/perl/kcpassword.html