Re-add ssh key every time I restart my mac

Every time I try to interact with git after I restart my machine I and given an error saying I have been denied access.

To fix this I enter the command

sudo ssh-add -K ~/.ssh/github_rsa

This works until I restart my computer and have to enter it again. This is the page that has helped me so far.

How can I get it so I don't have to enter this every time. Seems to work fine from other machines


For anyone else still looking, I found a working solution on Stackexchange, based on a question on Reddit that mentions this problem, specifically with macOS Sierra.

In addition to ssh-add -K you also have to create a new file ~/.ssh/config with this content:

Host *
   UseKeychain yes
   AddKeysToAgent yes
   IdentityFile ~/.ssh/id_rsa
   IdentityFile ~/.ssh/id_25519

Worked for me, hope this helps someone :)