Solve the Problem of requesting username and password for git push, instead of SSH-key verification

Source: Internet
Author: User

Reprinted from: https://blog.lowstz.org/posts/2011/11/23/why-git-push-require-username-password-github/

Previously, GitHub was used in Ubuntu according to the official new user guide. But I have been using fedora recently, so I also want to use GitHub under fedora. The configuration is very smooth, that is, I need to enter username and password every time I push git, I configured the public key to log on. Ssh-T [email protected] is also successfully logged on with the public key.

View the following information ~ /. Gitconfig, found the same as in Ubuntu, Google saw a GitHub introduction, which described two git push methods, ssh and HTTPS.

The SSH mode and https mode in the version library are different, specifically, the URL Information is different, but the actual authentication mechanism is also different. After a local key is created, you do not need to authenticate the key again in SSH mode, but you need to enter the password for HTTPS each time. "Help. GitHub-SSH key passphrases" also says that using SSH is more convenient and secure, so you do not need to enter a long password.

I checked. Git/config under the repo directory. Indeed, my URL is in HTTPS format.

123
[Remote "Origin"]Fetch = + refs/heads/*: refs/remotes/ORIGIN /*Url = https: // userna [email protected]/username/projectname. Git

Because the URL of the remote version library is https, it is estimated that I used the HTTPS link during git clone.

This is why the problem occurs. it is inconvenient to enter the user name and password every time.

To authenticate using the SSH public key, I changed the config URL to the following: (open the config file and click the URL)

123
[Remote "Origin"]Fetch = + refs/heads/*: refs/remotes/ORIGIN /*Url = [email protected]: username/projectname. Git

In this way, I can use the SSH Public Key for authentication during git push without entering the user name and password, which is convenient and safer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.