loading...

Store your git ssh in keychain (and make it persist across logins)

dvddpl profile image Davide de Paolis ・1 min read

Expecially during these times of remote work, I happened to be switching among different devices many times. I found very annoying that every time I needed to run some git push or pull I was asked for my git credentials.

I have an SSH key for that!

To use that key you need to add it to your keychain :

ssh-add -K ~/.ssh/[your-private-key]

This works pretty well, until you restart... If you are on Catalina you have to persistently store the key with a specific configuration:

touch .ssh/config
vi .ssh/config
--> i  ( to start typing in the file )
Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa
--> ESC (to exit from editing)
:wq  ( to save and close)

Credits go to this answer on Apple.StackExchange but this issue kept occurring to me and I found myself having to constantly google for it, so I decided to saving it here for future reference.

Posted on May 15 '19 by:

dvddpl profile

Davide de Paolis

@dvddpl

Sport addicted, productivity obsessed, avid learner, travel enthusiast, expat, 2 kids. πŸ‚βœˆπŸšžπŸŒπŸ“·πŸ–₯πŸ€˜πŸ‘¨β€πŸ‘©β€πŸ‘¦β€πŸ‘¦πŸš€ (Opinions are my own)

Discussion

markdown guide
 

Even pre-catalina the restart is not handled.

 

for non-osx system(i use fedora) the same works without the UseKeychain