Ask for password input when mounting a volume via Automator

I have Automator mounting a volume with hdiutil, but it requires a password to mount.

Natively macOS would prompt with a hidden-password input field; but I don't know how to trigger the same when running hdutil. In fact, running in an invisible bash script then the password prompt can't be shown.

So I've added "Ask for Text" to provide the password to the script, but this shows the typed password in clear plain text; that is not ideal for security reasons.

How can I show asterisks instead? Or how can I trigger the the native macOS mount password prompt?


I don't think the "Ask for Text" action provides that feature so you'll have to run an AppleScript command instead to display the dialog:

on run {input, parameters}
    return {text returned of (display dialog "Password:" ¬
        default answer "" with icon note buttons {"Cancel", "Enter"} ¬
        default button "Enter" with hidden answer)}
end run

which produces the following dialog:

Now, I don't know about hdiutil but this is how you might be able to use it: