2

I'm trying to get Git to work, which keeps insisting that I don't have the correct access right (Permission denied, publickey), which lead me to this post, suggesting to inspect ssh-add

I noticed that, indeed, ssh-add -l returned

The agent has no identities.

So, I added an identity

ssh-add ~/.ssh/ssh_key

Which returned exit code 0 (from echo $?)

Now, ssh-add -l shows that I have a key added. However, once I quit and re-open terminal, the key disappears. ssh-add -l returns "The agent has no identities." all over again.

Does anyone know how I can add the key so that it sticks?

altabq
  • 1,322
  • 1
  • 20
  • 33
  • Does `ssh-add -K ~/.ssh/ssh_key` work? – trojanfoe Jul 07 '20 at 12:49
  • 1
    Does this answer your question - https://apple.stackexchange.com/questions/254468/macos-sierra-doesn-t-seem-to-remember-ssh-keys-between-reboots? – Qumber Jul 07 '20 at 13:19
  • Are you doing anything special to (re)start `ssh-agent` in the first place? A freshly restarted agent has no keys initially. By default, though, `ssh-agent` is started when you first log in, independently of any shell sessions. – chepner Jul 07 '20 at 13:36

1 Answers1

1

You could add the ssh-add -K to your ~/.bash_profile

But check first if your SSH connection is working with a key not passphrase protected:

ssh-keygen -t rsa -P "" -f ~/.ssh/test

(register test.pub to the remote server ~/.ssh/authorized_keys or the remote GitHub profile SSH page)

 ssh -i ~/.ssh/test user@remote_server
 # or, if this is github
 ssh -T -i ~/.ssh/test git@github.com
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250