MacOS – Using the builtin dialog under OSX to unlock an SSH key

macossshterminal

OSX has a builtin passphrase dialog for ssh-agent, so that on the first use of a key, it'll get cached.

The problem is — I can't find a way to spawn that dialog by just adding ssh-add. ssh-add will only prompt for a passphrase on the terminal.

Somehow, the agent checks the existence of matching .pub and private key files and uses that to know which to ask for and spawn what I assume is a builtin dialog box.

I can work around this, hilarously, by also trusting that key for logging into "localhost", and putting "ssh localhost echo -n """ into my .bashrc, but this is dumb. If I can ssh-add and put the passphrase in on the terminal, I should also be able to use the builtin GUI.

(Why would I want to arbitarily unlock the ssh key before I log into anything, you may ask? Well, because bash-completion's ability to autocomplete things like the other side of an scp or rsync command requires an available auth mechanism — either Kerberos or an agented/unpassworded key.)

I'm annoyed that I can't find a reference for this anywhere else.

Best Answer

I think the dialog is because it is adding the ssh key to the keychain (as well as|instead of) to the .ssh/ files.

You should be able to invoke ssh-add -K and get the same results.