Mac Auto Login and Auto Lock
You may require a macOS installation to automatically login on boot (E.g. a server machine with launch services). However, for a little extra security you may want the system to login and immediately lock. Although this is not completely secure - if someone has access to your physical machine you’ve already lost. This just prevents someone walking past the machine and noticing it’s unlocked.
Create a suspend bash script (I’ll create it as /Applications/suspend.sh
):
#!/bin/bash
pmset displaysleepnow
Make it executable:
chmod +x /Applications/suspend.sh
Create a new Launch Agent plist at /Users/d/Library/LaunchAgents/com.d.suspendAfterLogin.plist
(in this case for username d
):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.d.suspendAfterLogin</string>
<key>Program</key>
<string>/Applications/suspend.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>