Skip to content

Instantly share code, notes, and snippets.

@badstreff
Created October 19, 2017 21:25
Show Gist options
  • Save badstreff/2dff8bb29648ff6f2a815b96ea246ebc to your computer and use it in GitHub Desktop.
Save badstreff/2dff8bb29648ff6f2a815b96ea246ebc to your computer and use it in GitHub Desktop.
Set Firmware Password macOS
#!/bin/bash
# Test for firmware password. If no firmware password set it.
fwpwdset="$(firmwarepasswd -check | sed 's/^.*: / /')"
if [ "$fwpwdset" = "No" ];then
echo "Firmware Password not set. Setting firmware password."
/usr/bin/expect << EOF
spawn firmwarepasswd -setpasswd
expect "Enter new password:"
send "$4\r";
expect "Re-enter new password:"
send "$4\r";
interact
EOF
else
echo "Firmware password already set."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment