4

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?

1
  • We haven't had any luck with this in our research so far. We've concluded this is no longer possible at the command line (without substantially more kowledge). We are using sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser to detect if it is enabled, and prompting with an error if it is not. Dec 12, 2016 at 21:21

1 Answer 1

9

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

It supports installation via homebrew:

brew tap xfreebird/utils
brew install kcpassword
1
  • Would this even work if FileVault is enabled? The macOS Settings app suggests otherwise.
    – huyz
    Jun 30 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .