ssh -A stopped working in macOS Sierra and keychain is not unlocked at login

Solution 1:

It seems that the ssh keys are not loaded by default into ssh-agent.

This solved the issue for me:

Edit your ssh config

vi ~/.ssh/config

Add the following

Host *
    IdentityFile ~/.ssh/id_rsa
    AddKeysToAgent yes
    ForwardAgent yes

Find out more information on reddit discussion: https://www.reddit.com/r/osx/comments/52zn5r/difficulties_with_sshagent_in_macos_sierra/

Solution 2:

The answer above works for RSA Keys, but once I had a DSA key, the solution had an additional step. Add the key using

ssh-add -K ~/.ssh/id_dsa

Then, edit or create the file ~/.ssh/config with the following content:

IdentityFile ~/.ssh/id_dsa
PubkeyAcceptedKeyTypes=+ssh-dss

After saving this file it should work.

Solution 3:

Sierra is now using OpenSSH 7.0 which has deprecated DSA keys.

If you need to use DSA keys still, add the following to the top of your ~/.ssh/config

Host *
    PubkeyAcceptedKeyTypes ssh-dss*