I am running into an issue trying to update keychain password with Applescript and Terminal.

I am currently using this :

set response to (display dialog "Do you know your previous password?" buttons {"No", "Yes"} default button "Yes" with icon caution) if button returned of response is "Yes" then
    tell application "Keychain Access" to activate
    tell application "System Events"
        tell process "Keychain Access"
            select row 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Keychain Access"
            delay 1
            click menu item "Change Password for Keychain “Login”…" of menu "Edit" of menu bar 1
            tell application "Keychain Access" to quit
        end tell
    end tell
end try

and want to use:

do shell script "security set-keychain-password" with admin privileges

But then it does ask for Old password, New password, and New passowrd again.

Is there anyway to get this to work, I am using this for work and for other users seeing a bunch of screen pop up is kind of nerve racking so I figure doing most of my script through Terminal will be better route.



This authenticates the user and unlocks if necessary the old keychain. It's by design, and ensures security practices are followed. If you really do want to alleviate the users' concerns you can educate them, update the keychains for them, or a whole host of other options. Bypassing OS X's security in the way you're asking though, I don't believe is possible and also isn't a good idea IMO.

  • I am not trying to bypass them, I want to still prompt for the Old password, new and re type new. But I am trying to have as little pop ups for the user so they dont get worried. So I want to do the shell version and have it prompt for the passwords in a dialog window. Instead of the Applescript version that prompts by onpening all windows – RayHumphrey Oct 31 '16 at 20:45
  • 1
    Then I don't understand - why not just use the shell version like you said? – Harv Nov 1 '16 at 19:12

You must log in to answer this question.

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