9

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

4
  • I think you don't need sudo for doing that...
    – konus
    Commented Sep 29, 2014 at 5:41
  • Without it says permission denied
    – Will
    Commented Sep 29, 2014 at 9:57
  • Well, that's odd. You should chown it (sudo chown youruser:staff ~/.ssh/github_rsa in order to regain permissions.
    – konus
    Commented Sep 29, 2014 at 11:48
  • I have given that a go. I will let you know how it goes. Cant restart my machine right now.
    – Will
    Commented Sep 29, 2014 at 12:46

1 Answer 1

13

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 :)

1
  • Thanks. This didn't work for me on macOS Monterey (yes, old Mac here). Any ideas?
    – chesterbr
    Commented Jun 17, 2023 at 22:36

You must log in to answer this question.

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