Home > Software engineering >  Problems pushing to Github "Authentication failed"
Problems pushing to Github "Authentication failed"

Time:06-23

I'm a newbie and maybe that's a dumb problem but when I'm trying to push my portfolio to github I'm getting "fatal: Authentication failed for 'https://github.com/username/Portfolio.git' I've googled the question and it led me here but people were talking about tokens and stuff that I don't understand. Any help or guidance will be very appreciated.

CodePudding user response:

Github is using SSH keys to identify you and your machine.

Generating GitHub SSH Keys

ssh-keygen -t rsa -C "[email protected]"

enter image description here

This will generate new id_rsa and id_rsa.pub keys in your ~/.ssh/ directory. (You need to locate your id_rsa.pub and get the key using any text editor)

To upload this newly created key to GitHub, go to:

Account Settings enter image description here SSH Keys Add SSH Key Paste your key where applicable - cat ~/.ssh/id_rsa.pub or Notepad in windows to get the contents. enter image description here Add Key Connect

For more information you can follow here

CodePudding user response:

I see your problem is trying to push to Github via HTTPS. Your error is usually caused by the authentication error while authenticating using a username and password.

Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

To solve your problem, I suggest you create a personal access token as described here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

Once you generate your personal access token, you can use it as a password. Personal access token only shows once, so keep it in a safe place and you can use it again in the future.

But you can also save it as a cache, so Github won't ask you to authenticate every time you clone, push, pull, etc by running this code before doing Github commands:

git config --global credential.helper store
  • Related