When a user persists an encrypted disk (or disk image) passphrase in the Keychain (e.g via Disk Utility as shown here, https://apple.stackexchange.com/a/229309/5392 or when setting up an encrypted Time Machine backup, possibly on a remote device), an entry gets created in either the login (via Disk Utility) or System (for Time Machine) keychains.
Examining such an entry with security
provides the following data:
$ security find-generic-password -D "disk image password" -l "A65D7474-F452-51CB-9BCC-3D594C918978.sparsebundle"
keychain: "/Library/Keychains/System.keychain"
version: 256
class: "genp"
attributes:
0x00000007 <blob>="A65D7474-F452-51CB-9BCC-3D594C918978.sparsebundle"
0x00000008 <blob>=<NULL>
"acct"<blob>="17F24503-E0E2-45B9-86EA-C79D857BA2AC"
"cdat"<timedate>=0x32303137303131303132333130335A00 "20170110123103Z\000"
"crtr"<uint32>=<NULL>
"cusi"<sint32>=<NULL>
"desc"<blob>="disk image password"
"gena"<blob>=<NULL>
"icmt"<blob>=<NULL>
"invi"<sint32>=<NULL>
"mdat"<timedate>=0x32303137303131303132333130335A00 "20170110123103Z\000"
"nega"<sint32>=<NULL>
"prot"<blob>=<NULL>
"scrp"<sint32>=<NULL>
"svce"<blob>="A65D7474-F452-51CB-9BCC-3D594C918978.sparsebundle"
"type"<uint32>=<NULL>
The account's GUID matches none of the users that can be found via:
dscl /Search -list /Users GeneratedUID
The ultimate goal is to non-interactively create the necessary entry in the Keychain for Time Machine to pick up the password and attach an encrypted, size-limited sparsebundle disk image on a Time Capsule, for which this is the missing piece.
Unfortunately diskimages-helper
is not allowed to mount it (observed via Console.app
) when using the following command to create the entry:
sudo security add-generic-password -a "$username" -w "${passphrase}" -D "disk image password" -s "${sparsebundle}" -T /System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/Resources/diskimages-helper /Library/Keychains/System.keychain
BTW this is on Sierra.
Additional references:
- https://sliwinski.com/mac-osx-lion-secure-backup-to-time-capsule-wi/
- How do I tell if a disk image (.sparseimage) is encrypted?
- https://techanic.net/2012/10/14/programmatically_mounting_encrypted_disk_images_in_os_x.html
- http://www.practiceofcode.com/post/749686705/encrypted-rotating-time-machine-backups-on-snow
- http://hints.macworld.com/article.php?story=20080519051720677