2

Upon generating ssh-keys to github account, I create a new file to hold the the keys as:

  ssh-keygen  -f ~/.ssh/github 

Then do the following steps:

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

Add add the public key to github account.

However, after restart the machine, it prompt that I have not the access to the private repo,

I have to repeat

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

to gain the access to the repository.

Everytime, I re-login a terminal, the above steps should be repeated.

How could solve the problem?

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138

1 Answers1

2

You could follow "Auto-launching ssh-agent on Git for Windows" (valid also for Linux), by copying into your ~/.profile or ~/.bashrc file in Git shell functions which can start the SSH agent for you.

The .bashrc is the one which will be always read, as in "What are the functional differences between .profile .bash_profile and .bashrc"

.bash_profile or .profile is read by login shells, along with .bashrc; subshells read only .bashrc

Make sure your SSH key is working (ssh -i /path/to/private/key git@github.com), because recent version of Git uses the new OpenSSH format.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250