问题
I am trying to push edits from within my pythonanywhere [hosting] account to the origin master at GitHub and fail.
It asks for my GitHub username and password. And it shows the following error, despite providing the correct credentials:
remote: Anonymous access to akhyansh13/simplifier.git denied.
fatal: Authentication failed for 'https://www.github.com/akhyansh13/simplifier.git/'
How do I push?
回答1:
I would recommend setting up public key authentication.
Open a Bash console and then use:
ssh-keygen
To generate an ssh key. you can choose to add a passphrase if you want to encrypt it (later on, you can look into ssh-add and ssh-agent to do some "remember my passphrase" magic, but it's optional).
Then
cat ~/.ssh/id_rsa.pub
To print out your public key. Then go to github, open your account settings, and choose "add key", and copy and paste the public key above
Be aware that weird things happen sometimes when you copy + paste from pythonanywhere. Either paste it into a text editor first and remove any newlines and spaces, or, instead of using the public key from the bash shell, navigate to it using the "Files" tab.
Once you have those set up, you'll be able to use the git@
urls for your repos. To change an existing one, do:
git remote rm origin
git remote add origin git@github.com:akhyansh13/simplifier.git
Then, finally, you can
git push -u origin master
To push your commits up. The -u
sets the local master to be synced with origin/master.
回答2:
In enterprise github, if you change the password of your logon, the change happens to all accounts. For example, in my case everything is tied to Active Directory. So, when I changed my windows logon creds, even git push
failed with Authentication error. In such a scenario, just re-login to GitHub using your browser and windows should show a pop-up, for you to enter the new password.
The problem arises due to password being cached by windows.
This is an old question, just posting if it helps someone.
回答3:
This could also be the result of Github not "liking" the IP you are pushing from.
来源:https://stackoverflow.com/questions/24551561/git-push-authentication-fails