Mounting encrypted disk images via Keyboard Maestro

I’m new to Keyboard Maestro and have been trying to build a macro that will move sensitive client files into a encrypted 2018-12 - g image that I’ve created with disktool

The macro checks to see of the container is mounted. If, it moves files and detaches the container.

If the container is not mounted, it mounts, asks for pw, waits until avaliable for the os and moves the files. It finally detaches the container via a simple shell script tha calls hdiutil on macos (hdiutil detach /Volumes/Gringotts/)

So far I have the macro working, but it seems that macOS os not asking for the passcode every time I open the dmg file. Hence, I suspect it is stored somewhere in memory.

Anyone knows for to force a passcode or to flush the passcode when the dmg file is detached ?

I’m sure there are smarter ways of doing this and would appreciate some input:

Instead of .dmg files I use encrypted sparsebundles, see

Then I also use macros to check whether the drive is mounted or not, probably similar to the ones you’re using:

Then, in my Keychain, I made a new password entry that I call in the macro and save into a variable. (This variable gets nulled again at the end of the macro so the pw doesn’t hang around.)

This combination never fails to ask for a password, running OSX High Sierra…


Thank’s Christian - I try that out :smile:

Something must have happened to the passphrase enroute to mojave (10.14.3b2) Also using sparsebundle is freely attach, detach and eject with not passcode prompts. I am sure it’s not in my keychain.

But thank’s for pointing out the sparsebundle instead dmg files :slight_smile: