Usable Keychain Scripting For Lion

July 29th, 2011

I’m tracking down a mysterious behavior of Safari in Lion, where it seems to fail to enter my password for logins that I’ve saved to the keychain. In the process of looking into this, I noticed that “Keychain Scripting” has mysteriously disappeared from Lion. As far as I can tell you must copy Apple’s scripting addition from Snow Leopard in order to keep using it.

On the other hand, I wrote an alternative years ago, called Usable Keychain Scripting. Its main advantage over Apple’s implementation is that it is (or at least, was) enormously faster. Today I updated the app to be 64-bit compatible and to fix a pernicious bug in which the password value returned for a keychain item would sometimes have garbage appended to the end of it.

Download Usable Keychain Scripting 1.0b4

This is not a supported product, and your success with it may vary. But it has been very handy in the past for me, and hopefully it will come in handy for you if you need to script the keychain.

13 Responses to “Usable Keychain Scripting For Lion”

  1. James Bailey Says:

    This is exactly what I need. My homemade username/password scripts stopped working in Lion. I didn’t want to download the SL version of keychain scripting. I’ll try your solution over the weekend. Thanks for this. My passwords are auto generated and I have no idea what they are.

  2. Daniel Jalkut Says:

    Thanks, James. I hope it works well for you.

  3. Robert Loomans Says:

    Any idea why a script like this doesn’t work?

    tell application “Usable Keychain Scripting”
    unlock keychain “Open.keychain”
    end tell

  4. Daniel Jalkut Says:

    @Robert – It looks like Usable Keychain Scripting is using the full path name of the keychain as its name. This doesn’t seem like a great thing for it to do, but you can work around the problem by referring to the target keychain by its full path e.g.:

    tell application “Usable Keychain Scripting”
    set kcPath to (POSIX path of (path to home folder as string)) & “Library/Keychains/Open.keychain”
    unlock keychain kcPath
    end tell

  5. Ben Says:

    So glad I found this. Am still using Snow Leopard but the old Usable Keychain Scripting would place an extra character onto my passwords about 50% of the time and I couldn’t figure out why. This version seems to have stopped the problem.

    Thanks Daniel!

  6. James Bailey Says:

    Daniel,

    Your Usable Keychain Scripting app works very well and is almost direct replacement for the Leopard version. And it is many times faster. I’m quite pleased that my home-grown password system is working again.

    Thank you very much.

    James

  7. Daniel Jalkut Says:

    James, great to hear. I am glad it’s working out for you!

  8. Morten Scheel Says:

    Hi Daniel,
    I can’t seem to write a new password to a generic item in my login keychain.
    I use “set password to _string” inside the generic item’s tell block. There are no errors but the password doesn’t change. Am I doing something wrong?

    Thank you for writing this!
    Morten

  9. Daniel Jalkut Says:

    Hi Morten – unfortunately Usable Keychain Scripting doesn’t support writing to the keychains. I originally wrote the scripting addition as a workaround for Apple’s insanely slow Keychain Scripting, so it only made sense to address the reading. It also made me feel a little safer about sharing something that works with such sensitive data, that it would only do reading and no writing.

    That said, with the omission of Keychain Scripting from Lion, it might make sense to bite the bullet and add writability to it.

    Daniel

  10. Morten Scheel Says:

    Thanks for the answer Daniel.
    I hope you will bite that bullet. And if you do, I’d be happy to pay for the product. Unless I’m mistaken there’s no easy way to bulk change a lot of passwords on Lion right now.
    Thanks again for all your work.

  11. Daniel Jalkut Says:

    Hi Morten – you may want to take a look at Apple’s command line “security” tool, I haven’t looked too closely but it offers a lot of similar functionality to what an AppleScript interface does, and may allow you to mass-update items.

  12. Vic Brown Says:

    Hi, I’m glad this is here. I can’t believe Apple doesn’t allow us to export. Ugh.

    Anyway, I downloaded this .dmg and can’t open it in Apple Script or open it like other .dmg files. What have I missed?

    Thanks

  13. Daniel Jalkut Says:

    Hi Vic – I don’t know what system you are running on. I just verified I can download and open the dmg on Mac OS X 10.7. I assume it still works on 10.6 as well but can’t guarantee other OS’s.

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.