简体   繁体   中英

where does git retrieve credential information from?

I have cloned a repo with ssh, made some change and tried to push but I got

remote: Permission to repo.git denied to <account_1>.

I have noticed that account_1 is not the user_id that I have been using. the user id is familiar and it seems to be left over from a long time ago

This was quite a surprise because I noticed that my other existing repo seems to work fine.

I checked with git config -l but account user emails were all fine.

Does anyone know what might be happening?

Git doesn't.

I have cloned a repo with ssh ...

It's ssh that handles authorization and credentials. Git does not have ssh built into it: Git just runs ssh. 1 So that means you can diagnose this just by running ssh.

It's very common—since GitHub do this among others—to use SSH to authenticate to a server using the git login, as in what you'll see with debug output by running ssh -Tvvv git@github.com . When you do this sort of thing, the way GitHub decides who you are is to inspect the key you send. If you have multiple different keys and wish to send one particular key to GitHub (or whatever other site), you can see which one you're actually sending using this sort of verbose test. Repeating -v three times like this— -Tvvv is equivalent to -T -v -v -v —raises the verbosity of ssh debug output to its maximum. The -T disables pty allocation, which is appropriate here since GitHub won't allow you to run a shell anyway.

To see how to configure your own ssh, see your particular system's ssh documentation, since this varies somewhat. In general, most of them use a directory (or folder, if you prefer that term) in or underneath your home directory to store configuration information and keys: $HOME/.ssh or $XDG_CONFIG_HOME/.config/ssh for instance.


1 Git does have libcurl built into it, but https authentication is more complex, so in general Git relies on OS-specific helpers here. Https authentication is far more varied than ssh, for whatever reasons; with ssh, you generally just say use this user name on this system and can provide all the arguments with a single invocation of ssh. With libcurl, it's ... messier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM