remote: Permission to repository denied. URL returned error: 403
Asked Answered
G

11

9

Might be a duplicate question, but none of the available solutions seems to be working. Could be that Github changed Support for password since 13 Aug, 2021.

I have tried the following:

  1. Checked the username and password.
  2. Created a Personal Access Token.
  3. Rechecked the origin URL in .git/config file.

The error message:

Username for 'https://github.com': gandharvsuri
Password for 'https://[email protected]': 
remote: Permission to gandharvsuri/gandharvsuri.github.io.git denied to gandharvsuri.
fatal: unable to access 'https://github.com/gandharvsuri/gandharvsuri.github.io.git/': The requested URL returned error: 403
Gallicism answered 21/4, 2022 at 11:28 Comment(0)
T
32

This worked for me

When creating your Personal Access Token, ✅Check some of the checkboxes e.g

  1. ✅repo
  2. ✅workflow
  3. ✅user
  4. ✅write:discussion
  5. ✅admin:enterprise
  6. ✅admin:gpg_key

Well this worked for me Try this

Trilingual answered 27/9, 2022 at 15:44 Comment(0)
D
18

First you need to generate a new token.

My account - Setting - Developer Setting - Personal Access Token - Generate New Token

After you generate the token,

git remote set-url origin https://<token>@github.com/<username>/<repo>

For example,

git remote set-url origin https://ghp_
[email protected]/GitHubUser/AwesomeRepo
Diamond answered 21/4, 2022 at 21:6 Comment(3)
I tried this, but I'm still getting the error. Also now it's not asking for my username and password and directly giving me permission denied error (403).Gallicism
This is the actual answer.Hardshell
This worked for me, Thank youDumbarton
T
3

I got the same error for https connection. When I clone repo with ssh the problem was fixed.

I followed this link to generate SSH key-pair.

After you done that step on the link above:

ssh -T [email protected]

You're ready to use SSH.

Now I used VSCode to clone my repo. You can follow anyother tool or terminal as well.

Y

When the VSCode is opened, click to Clone Git Repository...

After that you can see the following:

clonePath

Now here, you need to enter your repos' SSH connection:

enter image description here

Just copy and paste that link and your repo will be cloned with SSH protocol. Thus, you can use VSCode or Github Desktop to push or pull or for any other request without https (Autentication token).

Tacmahack answered 20/6, 2022 at 23:56 Comment(1)
Also, this link can be used to change url for already cloned repos: docs.github.com/en/get-started/getting-started-with-git/…Tacmahack
P
2

I found solution of this problem.

Sometimes, it is because of not being able to get proper credentials from Windows Credentials Manager.

If so,

  1. Open Credential Manager by running the following at the command line:

    • Windows+R to enter the command:
    • control /name Microsoft.CredentialManager
  2. Manage git credentials

    enter image description here

  1. Restart git credentials
Proposition answered 9/4 at 20:20 Comment(1)
It works for me. Well, We have to do this setting every time?Deviationism
C
1

Try not pushing with VScode terminal or being signed in to a vscode account. Open a bash terminal/window and push from there. this worked for me.

Curassow answered 12/12, 2022 at 15:10 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Legalize
C
1

I got the same error, I use the SSH e.g., [email protected]:Example/Name-Of-Repo.git, instead of the HTTPS.

Circle answered 2/1, 2023 at 4:21 Comment(1)
That's an honest mistake, The UI isn't clear enough to see which one (out of HTTPS and SSH) is currently selected. Something Github should work on.Gallicism
S
0

I found success doing this within my codespace by just setting up ssh keys to github. Essentially I just ran the following commands:

ssh-keygen

I then enter till the key was generated. Then changed into the directory to get the public key.

cd /home/codespace/.ssh
cat id_rsa.pub

I copied that and threw it under my profile for ssh keys. You may have to re clone down your repo using ssh after this but this is a good solution if your using multiple git repos within your codespace! I'm currently using my codespace for a class and whenever I'm not programming I turn it off to avoid going over my free 60 hours.

Su answered 10/2, 2023 at 0:37 Comment(0)
D
0

provide an idea . make sure the ssh key was add into the github_account truely. then change the remote URL to the ssh ,the command following:

git remote set-url origin [email protected]://<Repositories.git>

Dibb answered 18/2 at 8:32 Comment(1)
Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?Dina
S
0

Go to Control Panel\All Control Panel Items\Credential Manager>Windows Credentials

Next>> delete the existing git hub credential

next>> again run the command git push or push from your code environment.

next>> it will ask for authentication

next>> enter your credentials

that's it, it will be done.

Seymour answered 9/8 at 6:12 Comment(0)
D
-1

The solution for me was to make sure the git remote url was set properly:

git remote set-url origin <blabla.git>

After that, it worked like a charm...

Derina answered 27/11, 2022 at 19:18 Comment(0)
T
-1

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

git remote set-url origin [email protected]:/.git

ssh -T [email protected]

test ssh git remote set-url origin [email protected]:ragOP/vc.git

Tourbillion answered 11/3 at 18:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.