You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide shows how to import into pass your passwords stored in Apple's Keychain Access.
Find your keychain file
The default kaychain file is ~/Library/Keychains/login.keychain.
Passwords under the "Local Items" keychain (the default since Mavericks to sync with iCloud) use a different file format and can not be exported via the Apple's security tool we use. If that is you case, create a new keychain and drag-and-drop the keys. Your new keychain should have the .keychain extension.
Export the keychain to plain text file
To export a keychain you can use Apple's secure utility from the terminal. Run:
A pop-up will appear asking for the keychain password for every key. This behaviour cannot be changed.
To automate this process, you can use script provided easy-export-apple-keychain.applescript that asks for the password one time and auto-fills all the pop-ups. Open and run it from the Script Editor app under /Applications/Utilities. When running, the process is invasive and you will see all windows appearing and closing, so just let it finish. Bear in mind you won't be able to use your desktop for some time. It takes ~1 second per password.
(read-only) Identifies the creation date attribute. You use this tag to get a value of type string that represents the date the item was created, expressed in Zulu Time format ("YYYYMMDDhhmmSSZ"). This format is identical to CSSM_DB_ATTRIBUTE_FORMAT_TIME_DATE (cssmtype.h). When specifying the creation date as input to a function (e.g. SecKeychainSearchCreateFromAttributes), you may alternatively provide a numeric value of type UInt32 or SInt64, expressed as seconds since 1/1/1904 (DateTimeUtils.h).
mdat
(read-only) Identifies the modification date attribute. You use this tag to get a value of type string that represents the last time the item was updated, expressed in Zulu Time format ("YYYYMMDDhhmmSSZ"). This format is identical to CSSM_DB_ATTRIBUTE_FORMAT_TIME_DATE (cssmtype.h). When specifying the modification date as input to a function (e.g. SecKeychainSearchCreateFromAttributes), you may alternatively provide a numeric value of type UInt32 or SInt64, expressed as seconds since 1/1/1904 (DateTimeUtils.h).
desc
Identifies the description attribute. You use this tag to set or get a value of type string that represents a user-visible string describing this particular kind of item (e.g. "disk image password").
icmt
Identifies the comment attribute. You use this tag to set or get a value of type string that represents a user-editable string containing comments for this item.
crtr
Identifies the creator attribute. You use this tag to set or get a value of type FourCharCode that represents the item's creator.
type
Identifies the type attribute. You use this tag to set or get a value of type FourCharCode that represents the item's type.
scrp
Identifies the script code attribute. You use this tag to set or get a value of type ScriptCode that represents the script code for all strings. (Note: use of this attribute is deprecated; string attributes should always be stored in UTF-8 encoding.)
labl
Identifies the label attribute. You use this tag to set or get a value of type string that represents a user-editable string containing the label for this item.
invi
Identifies the invisible attribute. You use this tag to set or get a value of type Boolean that indicates whether the item is invisible (i.e. should not be displayed).
nega
Identifies the negative attribute. You use this tag to set or get a value of type Boolean that indicates whether there is a valid password associated with this keychain item. This is useful if your application doesn't want a password for some particular service to be stored in the keychain, but prefers that it always be entered by the user. The item (typically invisible and with zero-length data) acts as a placeholder to say "don't use me."
cusi
Identifies the custom icon attribute. You use this tag to set or get a value of type Boolean that indicates whether the item has an application-specific icon. To do this, you must also set the attribute value identified by the tag kSecTypeItemAttr to a file type for which there is a corresponding icon in the desktop database, and set the attribute value identified by the tag kSecCreatorItemAttr to an appropriate application creator type. If a custom icon corresponding to the item's type and creator can be found in the desktop database, it will be displayed by Keychain Access. Otherwise, default icons are used. (Note: use of this attribute is deprecated; custom icons for keychain items are not supported in Mac OS X.)
acct
Identifies the account attribute. You use this tag to set or get a string that represents the user account. This attribute applies to generic, Internet, and AppleShare password items.
svce
Identifies the service attribute. You use this tag to set or get a string that represents the service associated with this item. This attribute is unique to generic password items.
gena
Identifies the generic attribute. You use this tag to set or get a value of untyped bytes that represents a user-defined attribute. This attribute is unique to generic password items.
sdmn
Identifies the security domain attribute. You use this tag to set or get a value that represents the Internet security domain. This attribute is unique to Internet password items.
srvr
Identifies the server attribute. You use this tag to set or get a value of type string that represents the Internet server's domain name or IP address. This attribute is unique to Internet password items.
atyp
Identifies the authentication type attribute. You use this tag to set or get a value of type SecAuthenticationType that represents the Internet authentication scheme. This attribute is unique to Internet password items.
port
Identifies the port attribute. You use this tag to set or get a value of type UInt32 that represents the Internet port number. This attribute is unique to Internet password items.
path
Identifies the path attribute. You use this tag to set or get a string value that represents the path. This attribute is unique to Internet password items.
vlme
Identifies the volume attribute. You use this tag to set or get a string value that represents the AppleShare volume. This attribute is unique to AppleShare password items. Note: AppleShare passwords are no longer used by OS X as of Leopard (10.5); Internet password items are used instead.
addr
Identifies the address attribute. You use this tag to set or get a string value that represents the AppleTalk zone name, or the IP or domain name that represents the server address. This attribute is unique to AppleShare password items. Note: AppleShare passwords are no longer used by OS X as of Leopard (10.5); Internet password items are used instead.
ssig
Identifies the server signature attribute. You use this tag to set or get a value of type SecAFPServerSignature that represents the server signature block. This attribute is unique to AppleShare password items. Note: AppleShare passwords are no longer used by OS X as of Leopard (10.5); Internet password items are used instead.
ptcl
Identifies the protocol attribute. You use this tag to set or get a value of type SecProtocolType that represents the Internet protocol. This attribute applies to AppleShare and Internet password items.
ctyp
Indicates a CSSM_CERT_TYPE type.
cenc
Indicates a CSSM_CERT_ENCODING type.
crtp
Indicates a CSSM_CRL_TYPE type.
crnc
Indicates a CSSM_CRL_ENCODING type.
alis
Indicates an alias.
Protocol codes
In the file OSX/libsecurity_keychain/lib/SecKeychain.h we find the char code for the protocols supported, which may contain spaces or have uncommon spellings to fit into 4 characters:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*)
-- Select keychain file
set defaultPath to path to keychain folder from user domain
set keychain to choose file with prompt "Please select the keychain file to be exported:" of type {"com.apple.keychain"} default location defaultPath without invisibles, multiple selections allowed and showing package contents
-- Handle export file
set exportPath to (keychain as text) & "-export.txt"
tell application "Finder"
if exists file exportPath then
display dialog "The export file already exists: " & (POSIX path of exportPath) buttons {"Exit"} default button "Exit"
return
end if
end tell
set exportPath to (POSIX path of exportPath)
-- Get user password
display dialog "Type password to unlock keychain items" default answer "" with title "Set password" with icon note with hidden answer
set thePassword to the text returned of the result
-- Execute the exportation
do shell script "security -q dump-keychain -d " & quoted form of POSIX path of the keychain & " &>" & quoted form of exportPath & " &"
-- Autofill the passwords
delay 0.5
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent"
set frontmost to true
try
keystroke thePassword
delay 0.1
keystroke return
delay 0.1
on error
-- Skip error
end try
end tell
delay 0.5
end repeat
end tell
display dialog "Finished! Exported in " & exportPath