1

I generated the ssh pub key and private key and register pub key to my github. And add the private key by using this

$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa

But I have to put this command everytime when I push or pull the code. I hope to avoid this.

phd
  • 82,685
  • 13
  • 120
  • 165
mingxingwang
  • 169
  • 4
  • 17
  • Try referring to answers on [this post](https://stackoverflow.com/questions/10032461/git-keeps-asking-me-for-my-ssh-key-passphrase). – Rakhi Agrawal Apr 12 '21 at 07:14

1 Answers1

1

You should not have to write those commands everytime.

First, the agent is only needed if your private key is passphrase protected.

Second, as explained in "Working with SSH key passphrases", you should be able to automatically launch said agent through a ~/.bashrc resource file, or (for Mac) caching the passphrase in the keychain.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I add the .bashrc file and my private key is not default id_rsa so I put the command ```ssh-add ~/path/to/mykey ``` . Now I don't need to add ssh key everytime. Thank you! – mingxingwang Apr 13 '21 at 14:52