'Can't get personal access tokens to work with github for own repo
I've got a private repo I'm trying to push to, I'm on Centos 7. I cannot use SSH. Https says
No anonymous write access.
Stack overflow says to use personal access tokens. So I follow the directions, enable everysingle option under the token, and get a personal access token that looks something like:
ghp_xxxxxxxxxxxxxxxxxxxxxxx
I don't understand what I'm supposed to do with it though. I tried doing what one user said, and use my user name on github, with the access token as the password. Doing this:
(note copy pasted ghp_xxxxxxxxxxxxxxxxxxxxxxx below, where ghp_xxxxxxxxxxxxxxxxxxxxxxx is replaced by the actual token in real life)
[comp@comp-desktop my_fork]$ git push other_repo
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Username for 'https://github.com': MyUserName
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
Password for 'https://[email protected]':
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/MyUserName/my_fork.git/'
so I get the same issue.
Then I saw someone said to do something like:
git push https://<ACCESS_TOCKEN>@github.com/username/repo_name.git
so I did this:
git push https://[email protected]/MyUserName/my_fork.git
remote: No anonymous write access.
fatal: Authentication failed for 'https://[email protected]/MyUserName/my_fork.git'
Saw someone else put the name infront, this time I got no gui prompt, but still same result
git push https://MyUserName:[email protected]/MyUserName/my_fork.git
remote: No anonymous write access.
fatal: Authentication failed for 'https://MyUserName:[email protected]/MyUserName/my_fork.git'
So is it just impossible for me to use private repos on github?
Solution 1:[1]
First, make sure your token has at least the repo scope.
Second, the GitHub official documentation confirms:
$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token
Double-check the output of git config --global credential.helper to make sure nothing was cached. The only one I use on CentOS7 is git config --global credential.helper 'cache --timeout 3600'.
Check also your version of Git (I know on my CentOS7 server, it can be... quite old: 1.8.x! And yes, no SSH egress would ever be allowed)
Finally, from this thread, try and make sure you have 2FA activated for your GitHub account.
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 | VonC |
