gitgithubgit-bashssh-keysgithub-token

How to solve git@github.com: Permission denied (Public key) problem?


I was working with git to commit my files and folder to new repository. Everyone time when I was pushing my code it asked for username and password (which is github token for me). To avoid this I read solution on Configuring user and password with Git Bash given by @manojlds.

So I ran this command: git remote set-url origin git+ssh://git@github.com/username/reponame.git after reading it.

Now when I am pushing my code it neither the problem is solved nor it is giving me option to enter username and password(token)

After doing $ git push it is showing this

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

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

What should I do to revert it back and so that at least I can enter username and password(token) and upload my files and folder.


Solution

  • From August 13, 2021, no longer accepts Password-based authentication. Github provides a more secure alternative to it and ie. PATs(Personal Access Tokens).

    How to generate personal access token

    If you have done this properly, You can also refer this

    GitHub Error Message - Permission denied (publickey)