简体   繁体   English

git 从哪里检索凭证信息?

[英]where does git retrieve credential information from?

I have cloned a repo with ssh, made some change and tried to push but I got我用 ssh 克隆了一个 repo,做了一些更改并尝试推送,但我得到了

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.我注意到account_1不是我一直在使用的 user_id。 the user id is familiar and it seems to be left over from a long time ago用户id很熟悉,好像是很久以前遗留下来的

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.我检查了git config -l但帐户用户电子邮件都很好。

Does anyone know what might be happening?有谁知道可能会发生什么?

Git doesn't. Git没有。

I have cloned a repo with ssh ...我已经用 ssh 克隆了一个 repo ...

It's ssh that handles authorization and credentials.它是处理授权和凭据的ssh Git does not have ssh built into it: Git just runs ssh. Git 没有内置 ssh:Git 只运行ssh。 1 So that means you can diagnose this just by running ssh. 1这意味着您只需运行 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 .使用 SSH 通过git login 对服务器进行身份验证是很常见的——因为 GitHub 这样做了——就像你将通过运行ssh -Tvvv git@github.com看到的调试输出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.当你做这种事情时,GitHub 决定你是谁的方式是检查你发送的密钥。 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.如果您有多个不同的密钥并希望将一个特定的密钥发送到 GitHub(或任何其他站点),您可以使用这种详细测试查看您实际发送的是哪个密钥。 Repeating -v three times like this— -Tvvv is equivalent to -T -v -v -v —raises the verbosity of ssh debug output to its maximum.像这样重复-v三次-Tvvv相当于-T -v -v -v -v——将 ssh 调试输出的详细程度提高到最大。 The -T disables pty allocation, which is appropriate here since GitHub won't allow you to run a shell anyway. -T禁用 pty 分配,这在此处很合适,因为 GitHub 无论如何都不允许您运行 shell。

To see how to configure your own ssh, see your particular system's ssh documentation, since this varies somewhat.要了解如何配置您自己的 ssh,请参阅您特定系统的 ssh 文档,因为这会有所不同。 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.通常,它们中的大多数使用主目录中或下方的目录(或文件夹,如果您更喜欢该术语)来存储配置信息和密钥:例如$HOME/.ssh$XDG_CONFIG_HOME/.config/ssh


1 Git does have libcurl built into it, but https authentication is more complex, so in general Git relies on OS-specific helpers here. 1 Git确实内置了 libcurl,但 https 身份验证更复杂,因此通常 Git 依赖于特定于操作系统的帮助程序。 Https authentication is far more varied than ssh, for whatever reasons;无论出于何种原因,Https 身份验证都比 ssh 多得多; 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.对于 ssh,您通常只说在此系统上使用此用户名,并且可以通过一次 ssh 调用提供所有参数。 With libcurl, it's ... messier.使用 libcurl,它变得……更加混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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