Reputation: 108
Is there any way to reset Useraccount password in mac using shell script. I know we can take user input using dialogue box, but how can we send it to terminal app
Upvotes: 0
Views: 4137
Reputation: 89519
I can get you most of the way to the answer you need, but you'll have to do the actual implementation yourself.
1)
The first thing you need to do is to use the dscl
(Directory Service Command Line) tool.
Here's how to create a new user and here is how to change the password, which would be a command that looks like:
sudo dscl . passwd /Users/administrator thePassword
2)
Now that you know how to change the password using the command line, you need to embed that functionality into an AppleScript.
Here is a related Q&A on a different forum that shows dscl
embedded in an Applescript.
If you look in that above thread, you'll see you will need to prefix your dscl
commands with sudo
though. That means the password has to be entered in each time the Applescript is run.
If entering in the admin password each time doesn't work for you, you'll need to do some extra work, or run the script from a LanchAgent.
The above is a lot of information that you have to go through, and as you can see what you are asking for is not the most trivial task (and it should not be, since you really don't want passwords to be easily changeable via malicious scripts or bots or trojans). I hope I did point you in the right direction to get to a solution, though!
Upvotes: 1