pri
pri

Reputation: 1553

How to setup Git Bash (msysgit) with a github token or ssh key

New to Git.

Followed all the directions from github help pages but simple commands like git pull and git push continues to prompt my password on each invocation. Specifically, I set the following:

I also setup ssh keys elaborately as per the steps mentioned in the help but password prompts don't go away.

Suggestions?

Upvotes: 5

Views: 21760

Answers (3)

Mark Longair
Mark Longair

Reputation: 467111

From your comment saying that the password that works at this prompt is your GitHub password, I strongly suspect that you've cloned your repository using the https URL rather than the SSH URL. You can change that with:

 git remote set-url origin [email protected]:whoever/whatever.git

... where you should replace the last parameter with whatever's shown when you click the "SSH" button on your repository's page.

(You can check what URL origin currently refers to with git remote -v.)

Upvotes: 9

knittl
knittl

Reputation: 265171

You have to start ssh-agent, then use ssh-add to add your key. This requires the password once per session. You can also add it to the end of /etc/bashrc to add the key automatically on startup.

Better yet, have a simple function to your key to ssh-agent:

eval `ssh-agent`;
trap "kill $SSH_AGENT_PID" 0;
add-key {
  ssh-add;
}

Upvotes: 0

Stefan Kendall
Stefan Kendall

Reputation: 67802

Did you sign your pub key with a password? If you sign your key with a password, you'll always be prompted for that key. If you want no password, re-generate your .pub file without a password and upload that to github. If anyone gets access to your machine, they can commit as you, of course.

Upvotes: 0

Related Questions