Applescript: Keychain Access

Hi Community,

So I finally got a new computer after about 5 years, and as great as the new one is, I sorely missing all of my Keychain Access passwords. Seeing as it is a pain to have to enter all of these passwords I've grown used to neglecting (and there are also a few I've found I can no longer remember), I went back to the old computer to get the passwords. However, there are a LOT of passwords, and although I've one by one gotten the three or four I desperately need for the time being, I really don't want to have to go through one at a time for EVERY password. Thus, I've turned to Applescript. Using the password of the account in the script, can anyone help me make a script that would make an array of all the passwords in my Keychain? Thank you so much!

Posted on Feb 20, 2012 6:43 PM

Reply
3 replies

Feb 21, 2012 1:15 PM in response to chumponimys

os X has the Keychain Scripting app (located at /System/Library/ScriptingAdditions/Keychain Scripting.app, but you can see its dictionary from the Applescript Editor's library pane). you ought to be able to use this to open the old keychain and copy the individual keys to a new keychain. I haven't worked much with this app, so this script is a big 'maybe', but it's someplace for you to start. this should copy all the keys across:


tell application "Keychain Scripting"

set kc1 to keychain "X"

set kc2 to keychain "Y"

unlockkc1with password "..."

unlockkc2with password "..."

repeat with thisKey in kc1

set copiedProperties to properties of thisKey

makenewkeyat end of keys of kc2with propertiescopiedProperties

end repeat

lockkc1

lockkc2

end tell

Feb 22, 2012 10:55 PM in response to chumponimys

Lion still has keychains - what gave you the idea it didn't? It seems they removed the Keychain Scripting utility (not sure why) but you can probably copy it from a Snow Leopard installation. or you could do it manually - use the Add Keychain... option from the File menu to locate and open the old key chain, and then just select all the keychains you want ot copy and drag them to your new login keychain.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript: Keychain Access

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.