'Github Token Expired

My Github token has expired.

I have already refreshed it but I can't push my content to my remote repository.

When I type:

git push -u origin master

I get the following:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Any help will be welcomed.

Thanks.



Solution 1:[1]

I believe, you are getting this “Permission denied!” message because you need to configure an SSH Key.

If you activated two-factor authentication, GitHub forces you to use SSH Key. There might be other reasons for GitHub to make people use SSH Key, I'm not sure about it.

But the solution is, you need to generate one SSH Key and you need to add that SSH Key to your GitHub account. And after that, you should be able to push your code to your remote repository in GitHub.

Note: After you are done with the steps in the links below, you should be able to pull and push by using Terminal/Command Line/Bash etc. But if you are using some IDE feature to pull and push, you might need to figure out how to use generated SSH Key's with your IDE.

To see how to generate an SSH Key, you can follow the instructions in the link below:

Generating a new SSH key and adding it to the ssh-agent

To see how to add the SSH Key you generated to your GitHub account, you can follow the instructions in the link below:

Adding a new SSH key to your GitHub account

If you already have one SSH Key, try to check if your ssh-agent is able to pick up or not by running the command below:

ssh -T [email protected]

If you can not see your GitHub username, it means that your ssh-agent is not able to pick your ssh-key or there is some issue with your ssh-key. To fix this, you can generate a new SSH Key by following the guide links I sent above.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cundullah Terzioglu