macOS Keeps Asking for SSH Passphrase

by Christian Mohn · Read in about 1 min (173 words)

I’m a big fan of Public Key authentication for SSH but I recently ran into an issue after adding my Public Key to a couple of new Linux VMs I use. The problem was that macOS kept asking for the SSH passphrase when connecting to them, which kind of defeats the purpose of using Public Key authentication in the first place.

Thankfully, the solution is pretty simple.

in ~/.ssh/config add the following to the end of the file, to allow usage of the Apple Keychain for SSH:

Host *
  UseKeychain yes

This simply allows the usage of the stored Public Key passphrase in the Keychain for all hosts.

Info

Note: You can specify this setting for specific hosts too if you want to, by replacing the asterix with the hostname and/or IP address for the host.

Apparently this was a change done in macOS Sierra, and I don’t know why I haven’t come across it before now!

Post last updated on July 15, 2020: Added hugo-notice addon-theme for nicer notification styles

About the author

Christian Mohn works as a Chief Technologist SDDC for Proact in Norway.

See his About page for more details, or find him on Twitter.

Sponsors