62

I followed everything in the GitHub tutorial: https://help.github.com/articles/generating-ssh-keys

I did all the commands in the directory of my repository. I reached the end of tutorial successfully and got the message: "Hi username! You've successfully authenticated, but GitHub does not # provide shell access."

However when I tried to do things such as push it still requested for my username and password.

onepiece
  • 3,279
  • 8
  • 44
  • 63
  • This is a comment, not an answer, but I never personally got Github to work directly via ssh. So what I did instead is just leave my SSH key there `git push git@github.com:name/repo` which authenticates via SSH. Perhaps you could give that a try. I couldn't tell you what I did, though, let's just say that.. it works and I don't want to break it. – Thomas Sep 14 '13 at 03:20
  • I tried that, it gave me: "Warning: Permanently added the RSA host key for to the list of known hosts." However, it still requires login -.- – onepiece Sep 14 '13 at 03:24
  • possible duplicate of [Git push requires username and password](http://stackoverflow.com/questions/6565357/git-push-requires-username-and-password) – tripleee Feb 02 '15 at 10:49
  • Expanding on the above answer: You can find your ssh link for the remote origin on your github repository page by clicking on the clone or download button and then clicking on the use SSH link on the top right of the dropdown. – Saz Feb 22 '20 at 14:02

4 Answers4

184

Check your remotes via git remote -v.

https:// URLs will always ask for a password, unless you configure a credential helper. More info on that in this question.

The simplest solution for password-less git access would be to use the git remote set-url command and set an SSH url for the existing repo.

In your case, git remote set-url origin git@github.com:name/repo.

Then you should be able to git push origin <branch> without being asked for a password.

Community
  • 1
  • 1
19

Good that you have correctly setup your git ssh now you need to reclone the git repository with ssh for example previously you would have done something like this :

git clone https://github.com/dangrossman/bootstrap-daterangepicker.git

this was a https clone now you need to clone with ssh as

git clone git@github.com:dangrossman/bootstrap-daterangepicker.git

you can find the ssh link from your github account same place where you found your https link. After this you can easily push without your password prompt .

It might though ask for your ssh unlock password. You then need to enter the paraphase you gave during the creation of your ssh key . If you left it blank it might not prompt for it .

kaushik gandhi
  • 768
  • 8
  • 14
3

I was able to stop the username & password prompt by opening .git/config from the base repo directory and changing the remote URL.

For example:

[remote "origin"]
    url = https://github.com/username/my-repo.git

should be changed to:

[remote "origin"]
    url = git@github.com:username/my-repo.git
Alex
  • 12,078
  • 6
  • 64
  • 74
1

I tried the answer marked as correct but couldn't make it work. This worked for me instead git remote set-url origin ssh://git@github.com/username/reponame

KMA Badshah
  • 895
  • 8
  • 16