macOS Keeps Asking for SSH Passphrase

Published by Christian Mohn · Read in about 1 min (157 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.


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 January 2, 2024: Add author

About is the digital home of Christian Mohn and Stine Elise Larsen.

The primary focus is on IT architecture and data center technologies like virtualization and related topics, but other content also pops up from time to time.