Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Quirk With SSH Keys in macOS Sierra

DZone's Guide to

A Quirk With SSH Keys in macOS Sierra

Have you noticed a quirk with using SSH keys with macOS 10.12 Sierra? You're not the only one.

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

Now that I've upgraded to macOS 10.12 Sierra, I've noticed that SSH requires me to enter my passphrase to keys every time I use them. This was a surprise, as it's not how 10.11 El Capitan worked.

This is how to fix it.

First, add your SSH key's passphrase to the keychain using ssh-add -K ~/.ssh/id_rsa (or any other key file). You can now use your SSH key without re-typing the password all the time which is very handy for use with GitHub, GitLab, Bitbucket, etc.

You can add as many keys as you like and ssh-add -l will show you which keys are registered.

When you reboot, you'll notice that ssh-add -l is empty, which is different from how it works on macOS 10.11 as well as previous versions, which automatically re-added the keys it knew about. In Sierra, Apple has changed it so that you now need to explicitly add the known identities to the SSH agent. This is done using ssh-add -A, which you need to run every time you reboot.

To save having to do this, you can either add ssh-add -A to your ~/.bash_config file or update your SSH config by editing ~/.ssh/config and adding:

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:
ssh ,passphrase ,macos ,sierra ,devops

Published at DZone with permission of Rob Allen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}