0

Alright, I use git through vagrant to update projects I work on, and I am still using basic authentication instead of the token authentication. And that's not going to work after Friday, so, I need to update that.

Only I'm not sure how.

If I do this command "sudo git config --list --global" in vagrant, I get:

user.name=my username

user.email=my email address

And when I do this command "sudo git config --list --local", I get a lot more stuff, none of which I think I need to change, because it's stuff like "your origin is this url, your upstream is this other url, etc."

Notably, my password isn't in there anywhere, but I suspect that it's not shown for security reasons. (I know that currently, if I push some changes to the origin, I don't need to put in my password.)

So, my question is, how do I set the authentication token in those credentials? Failing that, if I can't, how do I 'unset' my password so that it asks for my token?

P. Gearman
  • 1,138
  • 11
  • 14

1 Answers1

0

The user.name and user.email settings are not authentication settings.

Git itself does not store your password anywhere, because Git itself never does any authentication in the first place, so it does not need your password.

When one Git installation (your laptop software, e.g.) needs to talk to another (e.g., on GitHub), Git invokes additional software, such as the routines for http/https access or the system for ssh access. These do do authentication, and may need a password. Since Git itself did not store one anywhere, they may rely on external helpers, such as Git's "credential helpers", or they may have their own methods of obtaining and distributing credentials. For instance ssh uses files and/or .

... my question is, how do I set the authentication token in those credentials? Failing that, if I can't, how do I 'unset' my password so that it asks for my token?

This depends on which program(s) you are using now for authentication. These are both OS-dependent and protocol-dependent: when using https://user@host/path/to/repo.git, Git is using the OS-specific libcurl code with OS-specific credential helpers, and when using ssh://user@host/path/to/repo.git (or the user@host:path/to/repo.git syntax that is shorthand for this in Git), Git is using ssh.

See also:

and similar results from a Google search now that you know the magic words. When using ssh—which is the method I prefer by far—see ssh documentation (there is a great deal of this; it gets complicated).

torek
  • 448,244
  • 59
  • 642
  • 775
  • Okay, so I used "echo url=my_github_url | git credential fill" and it showed me my credentials, including my password. Do I add the token in there somewhere? Or do I just nuke my ~/,git-credentials file on Friday, and when it asks me for my username and password after that, I just use my username and token? – P. Gearman Aug 09 '21 at 20:45
  • There's a `credential erase` sub-command for being more picky about it, but I'd probably just remove the file entirely myself. Once you're using a PAT it should be somewhat safer to leave it around as cleartext, but consider switching to ssh, or at least using one of the credential-storers that only acts as a temporary cache, too. – torek Aug 09 '21 at 23:25