11 Replies Latest reply: Mar 5, 2008 5:02 PM by baltwo
user1724 Level 3 Level 3 (530 points)
keychain is nice, but you need to be able to dump its contents. i see no way to export the contents to a readable file. i know i can backup the keychain, but that is not the same thing. you still need the keychain app to access the information. i don't want to invest the time to put in 100's of items if i cannot get them out.
  • 1. Re: keychain dump
    iPhone Genius Level 1 Level 1 (35 points)
    Delete the keychain preferences in Macintosh HD>System>Library. Best of luck.
  • 2. Re: keychain dump
    user1724 Level 3 Level 3 (530 points)
    That sounds dangerous. Do you have a reference for that or believe for some reason that works? And what exactly will that do?
  • 3. Re: keychain dump
    Tony T1 Level 6 Level 6 (8,385 points)
    Are you trying to dump the keychain contents to a text file so that the passwords are readable?
  • 4. Re: keychain dump
    amulz Level 1 Level 1 (10 points)
    Tony T1 wrote:
    Are you trying to dump the keychain contents to a text file so that the passwords are readable?


    Close, he wants a safe file format for the keychain contents so that he can keep it as a secure easily recoverable file. Security is nothing without the ability to recover information.

    Sorry, I have no idea what will do what you want.
  • 5. Re: keychain dump
    Chris Noble Level 4 Level 4 (2,670 points)
    I think you may have misinterpreted the meaning of the word 'dump'. The poster wants to make a copy, not delete the data


  • 6. Re: keychain dump
    baltwo Level 9 Level 9 (60,125 points)
    I have a simple AppleScript which generates a tab-delimited text file, named Passwords saved to the Desktop containing the name, account username, and password for each key in my login.keychain. The file is a backup for all generic and webpage keys. Note that it *hasn't been tested in Leopard*, but should do the job.

    Cut and paste it into Script Editor, compile it, and run it. Select the right-hand option in the dialog boxes that pop up; either allow always or allow once, whichever is not grayed out.

    Paste the file's contents into Excel, sort it by name, clean it up a bit, print it out, and you have a permanent record of each password item (key), sorted by name, username, and password. Store it in a secure location.

    <script>
    set osXKeychainScriptingPath to ¬
    (path to scripting additions from system domain as Unicode text) ¬
    & "Keychain Scripting.app:" -- one line
    set theSecuridPIN to {}

    tell application "Keychain Scripting" to launch
    tell application "Keychain Access" to launch

    using terms from application "Keychain Scripting"
    tell application osXKeychainScriptingPath
    set KeyList to every Internet key of current keychain
    repeat with aKey in KeyList
    set theSecuridPIN to theSecuridPIN & ((name of aKey) & tab & ¬
    (account of aKey) & tab & (password of aKey) & return) as text
    end repeat
    end tell
    end using terms from

    tell application "Keychain Scripting" to quit
    tell application "Keychain Access" to quit

    tell application "Finder"
    open for access file (((path to desktop folder) as text) & ¬
    "Passwords") with write permission
    set theFile to result
    write theSecuridPIN to theFile
    close access theFile
    end tell
    <end script>

    Tested in Tiger and Leopard.
  • 7. Re: keychain dump
    user1724 Level 3 Level 3 (530 points)
    amulz wrote:
    Tony T1 wrote:
    Are you trying to dump the keychain contents to a text file so that the passwords are readable?


    Close, he wants a safe file format for the keychain contents so that he can keep it as a secure easily recoverable file. Security is nothing without the ability to recover information.

    Sorry, I have no idea what will do what you want.


    You hit the nail right on the head.
  • 8. Re: keychain dump
    user1724 Level 3 Level 3 (530 points)
    baltwo wrote:
    I have a simple AppleScript . . .


    Looks promising. I have not studied AppleScript (just got my Mac last week). I do not load scripts and things I do not understand and cannot maintain myself. If I do not find a better answer, I suppose it is a good time to dig in.
  • 9. Re: keychain dump
    baltwo Level 9 Level 9 (60,125 points)
    I thought I corrected my post, but apparently missed this erroneous comment: *Note that it hasn't been tested in Leopard, but should do the job.*

    I and others have tested it and *it works in both Tiger and Leopard.*
  • 10. Re: keychain dump
    btd1924 Level 1 Level 1 (0 points)
    This works great. CAn you tell me what I need to modify to make it work the same on secure notes?

    Thanks

    btd1924
  • 11. Re: keychain dump
    baltwo Level 9 Level 9 (60,125 points)
    Thanks for the kudos. I have no idea about secure notes since I don't use them. Launch Script Editor, Window->Library and add Keychain Scripting to the list—it's in /System/Library/ScriptingAdditions/, double-click on it, and read its dictionary.