MacOS drops SSH GitHub access all the time.

Using MacOS Monterey 12.6 on a Mac Book Pro.


Every time I do a push I get the error: git@github.com: Permission denied (publickey)


And so every time I have to enter into the terminal:


ssh-add -l -E sha256
ssh-add ~/.ssh/id\_rsa 	


There must be a way of fixing this. Any ideas?


Many thanks

MacBook Pro

Posted on Sep 30, 2022 7:57 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 1, 2022 9:12 AM

Try this


ssh-add -K ~/.ssh/id_rsa    # add your passphrase to your macOS Keychain (may get a warning)


touch ~/.ssh/config

chmod 600 ~/.ssh/config


edit ~/.ssh/config and add the following:


Host *

   AddKeysToAgent yes

   UseKeychain yes

   IdentityFile ~/.ssh/id_rsa


You can remove your ssh-keygen key from your Keychain using:

ssh-add -K -d ~/.ssh/id_rsa    # remove your passphrase from your macOS Keychain


Similar questions

1 reply
Question marked as Top-ranking reply

Oct 1, 2022 9:12 AM in response to vincej1657

Try this


ssh-add -K ~/.ssh/id_rsa    # add your passphrase to your macOS Keychain (may get a warning)


touch ~/.ssh/config

chmod 600 ~/.ssh/config


edit ~/.ssh/config and add the following:


Host *

   AddKeysToAgent yes

   UseKeychain yes

   IdentityFile ~/.ssh/id_rsa


You can remove your ssh-keygen key from your Keychain using:

ssh-add -K -d ~/.ssh/id_rsa    # remove your passphrase from your macOS Keychain


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

MacOS drops SSH GitHub access all the time.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.