{"id":13538446,"url":"https://github.com/lifepillar/csvkeychain","last_synced_at":"2026-01-28T05:19:40.373Z","repository":{"id":50699031,"uuid":"86825151","full_name":"lifepillar/CSVKeychain","owner":"lifepillar","description":"Import/export between Apple Keychain.app and plain CSV file. ","archived":false,"fork":false,"pushed_at":"2019-01-19T18:40:56.000Z","size":54,"stargazers_count":353,"open_issues_count":9,"forks_count":48,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-15T17:36:50.642Z","etag":null,"topics":["apple","csv","export","import","keepass","keychain","password","security"],"latest_commit_sha":null,"homepage":null,"language":"AppleScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lifepillar.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-31T14:00:07.000Z","updated_at":"2025-02-15T19:23:15.000Z","dependencies_parsed_at":"2022-08-19T18:20:09.639Z","dependency_job_id":null,"html_url":"https://github.com/lifepillar/CSVKeychain","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lifepillar/CSVKeychain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifepillar%2FCSVKeychain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifepillar%2FCSVKeychain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifepillar%2FCSVKeychain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifepillar%2FCSVKeychain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lifepillar","download_url":"https://codeload.github.com/lifepillar/CSVKeychain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifepillar%2FCSVKeychain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28840088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","csv","export","import","keepass","keychain","password","security"],"created_at":"2024-08-01T09:01:12.152Z","updated_at":"2026-01-28T05:19:40.359Z","avatar_url":"https://github.com/lifepillar.png","language":"AppleScript","readme":"# CSVKeychain AppleScript script\n\nThis repo contains scripts to export all your password items and secure notes\nfrom Apple's Keychain.app into plain text files in CSV format, merge such files\nand import them back into a keychain.\n\nNo trick or reverse engineering is used: exporting is performed by Apple's\n`security` tool, using macOS's assistive support to streamline the process.\n\nThe current master should work in (High) Sierra.\nEarlier versions of macOS/OS X are not supported.\n\n\n## How to use\n\nTo import/export password items, open the AppleScript script in Script Editor.\nThe script may be run from source.\n\nBefore running the script, go to System Preferences \u003e Security \u0026 Privacy \u003e\nPrivacy \u003e Accessibility, and allow Script Editor to control your computer.\nThis step is\nrequired to avoid SecurityAgent to prompt you with a dialog for each item you\nwant to export. It basically allows AppleScript to press the Allow button in\nsuch dialogs for you.\n\nYou may also build the script into an application if you want. In this case, you\nmust grant the app control of your computer in the same way.\n\nThe script always asks for the password to unlock your keychain (you recognise\nthe dialog by the Script Editor icon). Since that dialog is not very\nsecure, it is recommended that you change your keychain's password in\nKeychain.app before exporting your keychain, and restore the original password\nafterwards. You may also be asked to unlock your keychain by SecurityAgent\n(which you do by providing your keychain's password). So, you may have to enter\nyour keychain's password once or twice. After that, SecurityAgent will keep\nprompting for a password for each exported item, but the script should fill it\nout for you automatically, so no further action from you will be required.\n\nThe script makes a backup of the keychain before importing or exporting data.\nBackups are timestamped and saved into the same folder containing the keychain.\nIn any case, it is a good idea to keep a separate backup, just in case.\n\nWhen importing items into a keychain, *matching items already present in the\nkeychain are overwritten if their timestamps are older than the timestamps of\nthe items being imported.* If there are items without timestamps in the CSV\nfile, the script will ask the user what to do with them. Note that this will be\nasked once and the choice applied to all the items being imported.\n\nAlso note that *all* new or updated items are assigned the current time as their\nnew timestamps. There is no possibility to retain the original timestamps from\nthe CSV file.\n\nFinally, access control lists are not exported.\n\n\n## Troubleshooting\n\nIf you get this error:\n\n```\nThis script will be terminated prematurely because the following error has\noccurred:\n\nsecurity: SecKeychainUnlock [...]: The user name or\npassphrase you entered is not correct. (Error number: 51)\n```\n\nopen Keychain.app and lock your keychain. Then, run the script again.\n\n## Merging files\n\nA Ruby script is provided to merge two CSV files containing password data into\none. See `./merge_csv.rb --help` for the details.\n\n\n## Is it possible to export the Local Items (aka iCloud) keychain?\n\n**Note: the workaround described in this section does not appear to work in\nmacOS High Sierra or later. You may have better luck with\n[Get passwords from iCloud keychain directly](https://discussions.agilebits.com/discussion/comment/455708/#Comment_455708)\nand [Get passwords from Safari](https://discussions.agilebits.com/discussion/comment/455305/#Comment_455305).**\n\nNot directly. The Local Items keychain, located at\n`~/Library/Keychains/\u003cUUID\u003e/\u003cname\u003e.db`, is a SQLite database containing\nobfuscated data, so its format is different from the format of a standard\nkeychain. As far as I can see, `security` cannot dump such keychains, and I do\nnot know of any tool that would do that.\n\nYou may proceed as follows:\n\n1. In Keychain.app, create a new keychain: File \u003e New Keychain…\n2. Select the Local Items keychain in the sidebar, then select all the items\n   (or the ones you want to export) and copy them by choosing Edit \u003e Copy.\n3. Select the keychain created at step one and choose Edit \u003e Paste.\n\nSuch process is painful, though, because Keychain.app will keep asking for\na password for each item. You may automate such process with [a bit of\nscripting](https://gist.github.com/rmondello/b933231b1fcc83a7db0b). For your\nconvenience, the script that allows you to fill in the password prompts for you\nis reported below:\n\n```applescript\ntell application \"System Events\"\n\trepeat while exists (processes where name is \"SecurityAgent\")\n\t\ttell process \"SecurityAgent\"\n\t\t\tset frontmost to true\n\t\t\ttry\n\t\t\t\tkeystroke \"PUT YOUR KEYCHAIN'S PASSWORD HERE\"\n\t\t\t\tdelay 0.1\n\t\t\t\tkeystroke return\n\t\t\t\tdelay 0.1\n\t\t\ton error\n\t\t\t\t-- do nothing to skip the error\n\t\t\tend try\n\t\tend tell\n\t\tdelay 0.5\n\tend repeat\nend tell\n```\n\nYou may run this directly from Script Editor. A similar approach can be used to\nexport `/Library/Keychains/System.keychain`.\n\n**Note:** Keychain.app won't allow you to paste some items (most likely,\nautomatically created by the system, not yours). In such case, the snippet above\nwill produce a script error and Keychain.app will show an error dialog, too.\nDismiss both and run the script again. Repeat every time you get an error.\n\n\n## Migrate passwords and notes into KeePass\n\nIf you want to import the CSV file generated by CSVKeychain into a KeePass\n2 database and you are on macOS, you may need to convert it to XML first. For\nsuch purpose, add a category column to the CSV file using the included\n`add_category.rb` script. Then, use my\n[csv2keepassxml](https://github.com/lifepillar/csv2keepassxml) to generate\na KeePass 2 XML file.\n\n\n## License\n\nCopyright (c) 2011–2018, Lifepillar\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["\u003ca id=\"06fccfcc4faa7da54d572c10ef29b42e\"\u003e\u003c/a\u003e移动\u0026\u0026Mobile","\u003ca id=\"58cd9084afafd3cd293564c1d615dd7f\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"dbde77352aac39ee710d3150a921bcad\"\u003e\u003c/a\u003eiOS\u0026\u0026MacOS\u0026\u0026iPhone\u0026\u0026iPad\u0026\u0026iWatch","\u003ca id=\"d0108e91e6863289f89084ff09df39d0\"\u003e\u003c/a\u003e新添加的"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifepillar%2Fcsvkeychain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flifepillar%2Fcsvkeychain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifepillar%2Fcsvkeychain/lists"}