1

OS version is Ventura 13.2

I generated an SSH key to authenticate git operations with GitHub according to their guide. Followed the steps:

  1. ssh-keygen -t ed25519 -C "my identifier" (Without passphrase. Saved to ~/.ssh/github)
  2. eval "$(ssh-agent -s)"
  3. touch ~/.ssh/config
  4. Added this to ~/.ssh/config:
Host *.github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/github
  1. ssh-add ~/.ssh/github

When testing the connection with ssh -T [email protected] it is successful, but after rebooting, closing the terminal, restarting vscode, etc, I have to manually re-add the SSH key using ssh-add again; otherwise I'm met with the error: [email protected]: Permission denied (publickey).

I expect the key to be added to the SSH agent automatically so that I may perform git operations without having to manually add the key to the SSH agent every time. It used to work before on my old MBP. How can I solve this?

1
  • When you "re-add the SSH key" are you just doing step #5, or are you also doing some of the others (esp step #2?)
    – Randall
    Jun 8, 2023 at 15:13

1 Answer 1

1

Your ~/.ssh/config file has a slight error in the hostname line.

Host *.github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/github

*.github.com will only match subdomains of github.com. Your ssh -T [email protected] is going directly to the main domain github.com which does not match *.github.com

Change that first line to Host github.com and you should be good.

 
PS - Welcome to AskDifferent!

0

You must log in to answer this question.

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