I am using Git on Linux.
I followed this to create a Personal Access Token but forgot to save it.
Therefore, when I was asked to enter the "password" again, I deleted the old PAT and created a new PAT. For some reason, the new token is rejected and I get
fatal: Authentication failed for 'https://github.com/username/***.git/'
When I look at the tokens page on github, this token says it was never used. What might be the issue here?
The issue might be with your current credential helper.
Type git config credential.helper to see which one is used.
Type:
printf "protocol=https\nhost=github.com"|git-credential-xxx erase
(Replace xxx by the credential helper name from the first command output)
That will clear out the cached credentials for https://github.com.
Then try again a git push, and see if it asks you for your credentials: enter your new PAT as password.
If you don't have a credential helper, I suggest installing microsoft/Git-Credential-Manager-Core (there is a Linux package).
Add a credential store, and you are set.
After discussion:
there was no credential helper
this is a personnal account (not a technical service one, used by multiple users)
the issue was with pasting the token
I would therefore use a store credential caching:
git config --global credential.helper 'store --file /home/<user>/.my-credentials
Then:
git ls-remote https://github.com/<user>/<repo>
That will trigger the prompt for your username and token.
Edit /home/<user>/.my-credentials and make sure the right token is in it.
Alternatively,
git config --global credential.helper 'store --file /home/<user>/.my-credentials'
and then:
git ls-remote https://<user>:<token>#github.com/<user>/<repo>
has worked.
I had to delete my token and create a new one and it worked for me
Related
I have the following module that we are trying to clone via SSH (NOTE: we prefer to not use https) in Terraform:
module "example-module" {
source = "git#github.com:private-org/example-module.git?ref=v1.0.0"
}
However, we have a GitHub actions runner that fails when trying to do a terraform init on this module:
Permission denied (publickey). Could not read Password for
'https://***#github.com': No such device or address
So to give this permission, we are trying to add inside .gitconfig:
[url "https://{GITHUB_TOKEN}#github.com"]
insteadOf = "ssh://git#github.com"
And inside the GitHub actions we are trying to replace GITHUB_TOKEN with the actual value:
- name: Configure SSH
run: |
sed -i 's/{GITHUB_TOKEN}/${{ secrets.GITHUB_TOKEN }}/g' .gitconfig
cat .gitconfig >> ~/.gitconfig
But we are still getting the same error. Any ideas for how we can authenticate to a private module inside our GitHub org and successfully clone via SSH?
Figured out the answer. The default GITHUB_TOKEN did not have have the right access rights and was not deemed a "Personal Access Token". This seems a little confusing on GitHub's part and the reason it was getting the error Could not read Password
You will need to generate a new personal access token in GitHub, and add that as a GitHub Actions secret called NEW_GITHUB_TOKEN. Add read:repo and write:repo as access rights and set the token to never expire.
Your .gitconfig should look like:
[url "https://{GITHUB_TOKEN}#github.com"]
insteadOf = "ssh://git#github.com"
And a step in your GitHub Actions that uses your new personal access token:
- name: Configure SSH
run: |
sed -i 's/{GITHUB_TOKEN}/${{ secrets.NEW_GITHUB_TOKEN }}/g' .gitconfig
cat .gitconfig >> ~/.gitconfig
I have a Node.js app. I want to clone a private repository from GitHub using this app. I have access to this repository. In an attempt to clone the repository from my Node.js app, I'm using simple-git, with the following code:
const git = simpleGit();
git.clone('[repository-url]', './repository');
This code runs successfully. A directory named repository with the following structure is created:
/repository
/.git
.gitignore
However, this is not the contents of the repository. I successfully cloned a public repository using this code. This makes me believe that it's an authentication issue, even though no error is being shown. I created a Personal Access Token and stored it in an environment variable. However, I can't figure out how to actually use that Personal Access Token when I clone my private repository.
How do I clone a private repository using a Personal Access Token using simple-git?
You can use the config plugin to add your access token as a custom header:
const git = simpleGit({
config: [
`Authorization: token ${TOKEN}`
]
});
You can also set up a .netrc file with your auth details which simple-git will pick up by default.
I am trying to migrate cvs to git repository. I tried to test how it works. So I tried to access cvs public repository using the doc
There is support to access cvs repositories with an anonymous account with an empty password, but I am unable to access it.
cvs -d :pserver:anonymous#cvs.infodrom.org:/var/cvs/$repository login
Logging in to :pserver:anonymous#cvs.infodrom.org:2401/var/cvs/config
CVS password:
cvs [login aborted]: unrecognized auth response from cvs.infodrom.org: /usr/bin/cvs: unrecognized option '--allow_root=/var/cvs/debian'
How can I access cvs repository with an anonymous user?
Two points:
Try using infodrom rather than config as a $repository value as that's what's documented here: http://www.infodrom.org/projects/cfingerd/cvs.php and in similar projects i.e.
cvs -d :pserver:anonymous#cvs.infodrom.org:/var/cvs/infodrom login
You normally need the whole server-side repo to do a proper cvs2git, not just a client-side checkout. Which you cannot get from a repo on the web, you can only get if you are the sysadmin on your own cvs repo.
Is there a way to configure my identity from inside Git-Gui, instead of having to go through Git-CMD?
I know how to do it through CMD, as it literally tells you. I'm just wondering if I need to use the CMD.
When I tried to merge something with the GUI for the first time, it's asking me to run:
git config --global user.email johndoe#example.com
git config --global user.name "John Doe"
Yes, at least on version 0.21 you can do it by opening a git repository folder then going to Edit->Option, then edit your user name and email address in the GUI.
I have a copy of a repo on my localhost with a saved username / password for the SVN repo.
The problem is that I changed my svn password (and would like to keep it that way) but every time I try to svn commit, it is asking for my GNOME keyring password (which I enter correctly). This is odd in the first place because I never had it ask me this before.
Then, after entering my password to the keyring, I get this error message:
svn: OPTIONS of 'PATH_TO_CHANGED_FILES': authorization failed: Could not authenticate to server: rejected Basic challenge (REPO_URL)
This is happening on 2 repos that I have but a 3rd one is just fine.
When I disable authentication on the server, everything commits just fine and if I try to update / commit from another server, it also works just fine.
I tried adding the following lines to my ~/.subversion/servers:
store-passwords = no
store-plaintext-passwords = no
And I also tried adding the following lines to my ~/.subversion/config:
store-passwords = no
store-auth-creds = no
But those config file changes do nothing.
Is there a way for my localhost svn to forget the username and passwords I have entered for these repos (they were saved before) so I can get back to everything?
I was able to solve this by deleting the keyring file for MATE. It is a bit of a brute way of doing it but it worked. You can delete the keyring file for MATE with the following command:
rm ~/.config/mate/keyrings/*.keyring
I don't know, how to remove stored data from keyring (old pass for repo), but you can try to replace it.
Use in console any SVN command, which will require authentication with additional options
Global options:
--username ARG : specify a username ARG
--password ARG : specify a password ARG
and test repo-communication in usual way after it
About keyring pass-request:
Check settings in ~/.subversion/config, [auth] section for password-stores =
Check settings in ~/.subversion/servers, [global] section for
store-passwords =
store-plaintext-passwords =