Enabling Root

Honored Contributor


We're looking at getting Random Password Manager working on OS X (already have it for our windows machines). RPM will spin the root account. Does anyone know how to script the enablement of the root account? Ideally, we'd enable it through Casper and then spin it with RPM.


Jared F. Nichols
Desktop Engineer, Infrastructure and Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420


New Contributor II

Hey Jared, sounds like fun!

I'm pretty sure you can just set the password of root and it will enable the root account.

So, if the admin user ran this script with the desired password as an argument:

#!/usr/bin/expect -f
set rootpw [lindex $argv 0]
match_max 100000
spawn passwd root
expect "New password:"
send "$rootpw "
expect "Retype new password:"
send "$rootpw "
expect eof

It SHOULD enable root with the password specified.

Example, create a script containing the above code called "enableroot.exp" and then run this:

./enableroot.exp ultramegasecret1334p0wneDpasswordgoeshere

Replace that ridiculous pw with yours, of course. :)

Let me know if you get stuck; good luck!

P.S. I've attached the scrip to save you some time. :)

Not applicable

I believe the 'dsenableroot' command will do what you want.

Clinton Blackmore

Honored Contributor

dsenableroot will work on I think 10.4 or later but please be warned
anything you put in a script, like a password will be stored in the logs
in plain text. Trust me this is not a good idea, and even if you think,
oh my users will never thumb through thousands of lines of a log file
and try everything that may look like a password, then you have never
met a high school kid with too much time on their hands.....

I think you would be best wrapping this up in an application and then
deploying it, so the only thing the log file says is the PKG was
installed successfully.

Thomas Larkin
TIS Department
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351