5

I may have not understood the use of SSH key in Github completely.

I followed the Github docs [https://help.github.com/articles/generating-ssh-keys/] to create SSH key on my laptop and import the same SSH key on my Github account.

However When I tried to push my local changes to a project I have forked, the git Bash still asks for my github user id and password.

enter image description here

My understanding was; once I have configured SSH, I do not have to provide my gihub user account, passwords when committing changes becuase SSH takes care of it.

1
  • 2
    Your origin address has https as the protocol - if you're using ssh, should it not be ssh:// ? Commented Jul 31, 2015 at 5:08

3 Answers 3

4

When you clone your github repository you can select http and ssh url for github project.

You can clone with HTTPS, SSH or Subversion.

I think you should select ssh to work with ssh authentication. Check your cloned git project's config. There is a remore url that you can change to ssh url.

Sign up to request clarification or add additional context in comments.

3 Comments

David, you are right, I cloned the same repo but with SSH and commits are not asking for github user id and passwords. However; assuming a user cloned his/her repo using https, is there a way to switch to SSH?
Yes, there is a .git folder in the project that contains a config file. You should edit that file. That's all.
thanks David. Will try that option. Accepting as correct answer.
2

Using the ssh key you have to download using the ssh url. if you have cloned the repo using the https method then you can manully override the https with SSH.

use below command to override.

git remote set-url origin git@hostname:USERNAME/REPOSITORY.git.

Let me know if it helps you.

Comments

2

You have to change your remote url: First of all you have to enter in your repo, then type:

git remote -v 

That lets you see your origin url which is probably like

https://github.com....

Now you have to change that by doing the following to set your new push url:

git remote set-url --push origin [email protected]:gitusername/repository.git

Than to change your fetch url you have to do

git remote set-url origin [email protected]:gitusername/repository.git.

Now if you again run

git remote -v 

You will probably see your new url. You can take the new url from the github page of your repo by pressing the code button and selecting ssh. You have to do it for all your old repos.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.