Git Bash是否通过ssh密钥确定身份? [英] Does Git Bash determine identify by ssh key?

查看:325
本文介绍了Git Bash是否通过ssh密钥确定身份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第3天会发生,我仍然无法解决以下问题:



我最初在2年前创建了一个GitHub帐户。我相信我为此帐户生成了一个SSH密钥。我相信我已经将ssh密钥加载到我的ssh-agent程序中,然后将公钥放在我的GitHub帐户上。



现在我最近创建了一个新的GitHub帐户。我创建了一个回购,然后将该回购克隆到我的PC。在提交一对夫妇后,我试图将更改推向回购。然而,它表示,我没有权限回购,声明'拒绝回执的权限 - oldusername没有访问权限'。所以看起来Git Bash在尝试推送更改时引用了我的oldusername。



我尝试通过'git config user.name'等来更改我的配置信息。等等。但是,这似乎没有解决问题。然后我偶然发现了一些说我需要SSH密钥的东西。我深入了解了这一点,并认识到我目前的Git Bash引用了一个与我的旧帐户相关的ssh密钥。所以我在我的计算机上删除了这个旧密钥,并且还从旧的GitHub帐户中删除了该密钥。

然后我开始生成一个新的SSH公钥/私钥对。我加载(或者我相信)新的私钥给ssh-agent。然后我将公钥添加到我的新GitHub帐户中。请注意,我还将'密码'选项留空,因为我不明白它的直接目的。



在这些更改之后,我试图推进我所做的更改到远程回购。但是,我再次收到错误oldusername无权将更改推送到回购。

所以看起来我的Git Bash仍在引用我的旧用户名。为什么是这样? Git Bash使用ssh-agent加载的ssh-key来确定你的身份吗?如果是这种情况,为什么它仍然会引用我的旧GitHub用户名?附:我在Windows 10,Git 2.9.3.2上。



有什么想法?

解决方案

我认为这里的关键是您使用HTTPS克隆了新的存储库。



我怀疑证书助手正在缓存您的凭证。看到这个:





,您的详细信息由您的Windows登录保护,并可以保留多个会话。这是在Git for Windows 1.8.1.1中添加的。



所以:


  1. 尝试使用以下方法清除HTTPS克隆的回购的凭证缓存,然后重试: git凭证-osxkeychain擦除主机= github.com协议= https


或,


  1. 使用Windows控制面板的凭证管理器编辑凭证。


It's going on day 3 and I have still not been able to resolve the following issue:

I originally created a GitHub account 2 years ago. I believe I generated an SSH key for this account. I believe I had loaded the ssh key to my ssh-agent program and then placed the public key on my GitHub account.

Now I recently created a new GitHub account. I created a repo and then cloned that repo to my PC. After making a couple commits, I attempted to push the changes to the repo. However, it stated that I didn't have permission to that repo stating something along the line of 'Permission denied to repo - oldusername does not have access rights'. So it appeared that Git Bash was referencing my oldusername when attempting to push the changes.

I attempted changing my config information via the 'git config user.name' , etc. etc. However, this didn't seem to fix the problem. I then stumbled across something stating that I need an SSH key. I looked further into this and came to the realization that my current Git Bash was referencing an ssh key associated with my old account. So I deleted this old key on my computer, and I also deleted the key from my old GitHub account.

I then proceeded to generate a new SSH public/private key pair. I loaded (or so I believe) the new private key to the ssh-agent. I then added the public key to my new GitHub account. Note that I also left the 'passphrase' option blank as I didn't understand the immediate purpose of it.

After these changes, I attempted to push the changes I made to the remote repo. However, I again received the error "oldusername doesn't have permission to push changes to the repo".

So it appears that my Git Bash is still referencing my old username. Why is this? Does Git Bash use the ssh-agent's loaded ssh-key to determine your identify? If this were the case though, why would it still be referencing my old GitHub user name? P.s. I'm on Windows 10, Git 2.9.3.2.

Any thoughts?

解决方案

I think the key here is that you used HTTPS to clone the new repository.

I suspect that your credentials are being cached by the credentials helper. See this:

https://help.github.com/articles/caching-your-github-password-in-git/#platform-windows

On windows, if you've used the wincred helper (git config --global credential.helper wincred), then this stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. See this for instance:

With this store, your details are secured by your Windows login and can persist over multiple sessions. This was added in Git for Windows 1.8.1.1.

So either:

  1. Try clearing the credential cache for your https cloned repo using the following and try again:

    git credential-osxkeychain erase host=github.com protocol=https

OR,

  1. Edit the credentials using the Windows control panel's Credential Manager.

这篇关于Git Bash是否通过ssh密钥确定身份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆