Wednesday, March 1, 2017

Adding a Private Key to macOS Keychain

On macOS, the native SSH client can use the built-in keychain directly which is awesome because you don't have to type in the password every time. To add your private key to the keychain simply use the command:

ssh-add -K /path/of/private/key

For example if your private key's filename is ~/.ssh/id_rsa, you would use the command:

ssh-add -K ~/.ssh/id_rsa

You will then be prompted to enter your password. From now on it's all automatic. Viola!

Update: There appears to be an issue in macOS Sierra where the password is only stored for the currently session. You can follow a thread here. I'll add more information as I run across it.

No comments:

Post a Comment