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.