Reputation: 133
I have tried everything mentioned in this thread: Pushing to Git returning Error Code 403 fatal: HTTP request failed
I created a GitHub repo on my MacBook Pro, pushed some work up to it from my Lenovo laptop, and am trying to continue work on my Mac. I had been authenticating using a PAT on Windows, but coming back to the Mac using the same PAT I'm getting this error.
I've tried generating new PATs but this hasn't worked. I haven't been pushing code up to GitHub for a couple of years, and I never even needed a password to do this before, and don't remember changing any developer settings?
This is the full message I get when trying to push with GitHub password
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/<username>/<reponame>.git/'
with PAT
remote: Permission to <username>/<reponame>.git denied to <username>.
fatal: unable to access 'https://github.com/<username>/<reponame>.git/': The requested URL returned error: 403
The 403 suggests I suddenly don't have access to my own repo, but I don't know how else I can authenticate than using the PAT. Has anyone encountered this and still remained stuck after trying everything in the above link?
Alternatively, is there any way to make this non-PAT or password protected? There isn't anything particularly sensitive here so it might not need this protective layer?
Upvotes: 8
Views: 18776
Reputation: 152
You can receive 403 if your organisation requires SSO configuration of the token and you missed to configure it.
Upvotes: 0
Reputation: 945
I had this error even after creating PAT and using it instead of password. I tried the following:
Change git origin from https:// to ssh Open terminal / cmd and cd to your cloned repository directory and run:
git remote set-url origin [email protected]:<github username>/<repository name>
which, of course gave me errors, but added github.com to the trusted hosts
The authenticity of host 'github.com (140.82.121.3)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. [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.
after that I changed remote url back to HTTPS one, and after that was able to use PAT successfully to authenticate. I accidentally discovered this after getting 403 for hours with correct PAT. I have Linux, you have Mac, which could explain similarities with working with trusted hosts, which wasn't an issue on Windows machine.
Upvotes: 0
Reputation: 416
Steps I used to solve this issue:
Repo begins cloning...
Things I tried before finding the solution:
Upvotes: 2
Reputation: 81
By default tokens always include read-only access to all public repositories on GitHub. Hence, to give push or pull and rights you need to select the appropriate "Scope" while creating access token.
The scope for public repositories is public_repo, and for private repositories is repo. A token with one of those scopes is the most limited access possible for Git push or pull access.
For the description of other available scopes refer the Github Documention.
Upvotes: 7
Reputation: 11
you do probably need to create either:
how to create an ssh log key:
that's it
hope it helps
Upvotes: -5