7

Supposedly this console command will add my private SSH key to the Apple Keychain, as discussed in this Answer on the Question, How to use Mac OS X Keychain with SSH keys?:

ssh-add -K path-to-my-private-key-for-SSH

If that succeeds…

➥ What is the type and name of the entry to be found in the Keychain Access.app?

I would like to be able to manually verify and possibly delete that entry.

5

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

3

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>
2
  • Yes, UseKeychain is required since 10.12.2 for ssh to automatically use the stored ssh key. AddKeysToAgent is optional though, only if you want it to automatically add all keys you use to the Keychain. – wisbucky Sep 18 '19 at 0:19
  • If you only want to use SSH agent, and not store passwords in Keychain, you can omit the UseKeychain option. – z0r Jan 6 '20 at 0:33
1

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.

0

In Keychain, just do a search for "ssh".

Or you can find it under:

Keychain: Local Items
Category: Passwords
Name: SSH: /Users/xxxxx/.ssh/id_rsa

You will most likely need to quit and restart Keychain to refresh the list. It helps to sort by Date Modified. You can also try View > Show invisible items.

Additional note:

ssh-add -K will add the key to the Keychain. However, ssh-add -D will not delete the key from the Keychain (it only deletes from ssh-agent/ssh-add -l). So you are right that is good to check the Keychain.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .