After running `ssh-add -K` to add my SSH key to the Apple Keychain, what is the name and type of entry shown in Keychain Access.app?

Solution 1:

If you key is not passphrase protected, it looks like macOS won't add it to the Keychain. Presumably this is because the only thing the keychain stores is the passphrase. Everything else seems to require messing with the ~/.ssh/config file.

If your ssh key is passphrase protected, running ssh-add -K path/to/key adds your passphrase to your keychain as a generic password prepended with "SSH:". Also, as for remembering keys, starting with macOS Sierra, Apple chose to stop remembering keys by default. See a brief article (with some external sources) about debugging some SSH problems: https://medium.com/@medley56_82999/i-recently-went-down-a-rabbit-hole-debugging-some-ssh-problems-cross-platform-and-wanted-to-make-bc6890eaf758

Solution 2:

It's a little fiddly, but this works on even the latest version of Mojave (as of Darwin 18.2.0)

Prior to Mac OS 10.12.2 (Sierra is 10.12):

Edit ~/.ssh/config:

    Host *
    AddKeysToAgent yes

Mac OS 10.12.2 or greater:

Edit ~/.ssh/config:

    Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/<private key filename>

Solution 3:

Open the keychain app, click on the category "passwords", click add, and put the path to the SSH file as the account name:

enter image description here

Now, ssh-add -A should automatically add the key to your ssh-agent without any further hassle.