4

所以我现在是 github 上的“jononomo”。然而,一年前,我是“zononomo”。我暂时退出软件并在此期间购买了一台新笔记本电脑。然后我回来并在 Github 上以“jononomo”的句柄创建了一个新帐户,现在我正在尝试在我的两台笔记本电脑之间同步我的 dotfiles。在我的新笔记本电脑上,我创建了一个 git 存储库并将其推送到 github,可以在“jononomo”帐户下查看它。然后我去了我的旧笔记本电脑并克隆了这个存储库。一切都按预期工作。

然后我对旧笔记本电脑上的点文件进行了一些更改,现在我想将这些更改推送到 github,以便我可以将它们拉到我的新笔记本电脑上。问题是当我运行命令时:

git push origin master

我收到错误消息:

ERROR: Permission to jononomo/.dotfiles.git denied to zononomo.

我做的第一件事就是把旧的 SSH 密钥~/.ssh/id_rsa~/.ssh/id_rsa.pub. 然后我生成了新的 SSH 密钥并将我的新公钥添加到我的 jononomo github 帐户中。但这并没有解决问题。如果我运行命令:

ssh -T git@github.com

我得到回应:

Hi zononomo! You've successfully authenticated, but GitHub does not provide shell access.

接下来,我按照这里给出的解决方案:https ://stackoverflow.com/a/8152291/1701170 这个人建议我创建一个~/.ssh/config包含以下内容的文件:

Host github-jononomo
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_dsa.pub

然后他建议我运行命令:

git remote set-url origin git@github-jononomo:jononomo/.dotfiles.git

我试过了,但它并没有解决我的问题。我仍然收到消息:

ERROR: Permission to jononomo/.dotfiles.git denied to zononomo.

顺便说一下,my.gitconfig有以下内容:

[user]
    name = Jon Crowell
    email = me@myemail.com
[github]
    user = jononomo
    token = 2a18a7235746324aefec34b234aa343a
    email = me@myemail.com
[credential]
    helper = osxkeychain
4

2 回答 2

3

我通过以下步骤使其工作:

首先我的~/.ssh/config文件如下:

Host github-jononomo
    HostName github.com
    User git
    IdentityFile  ~/.ssh/id_rsa
    IdentitiesOnly yes

其次,我运行了命令git remote set-url origin git@github-jononomo:jononomo/.dotfiles.git

三、我跑了命令ssh -T git@github.com,得到了结果Hi jononomo! You've successfully authenticated, but GitHub does not provide shell access.

第四,我登录了我的旧 github 帐户,删除了 SSH 密钥并彻底删除了该帐户。

非常感谢 VonC。

于 2012-10-26T19:26:37.237 回答
2

zononomo?GitHub 不应该再将您识别为 zononomo。
也许您有一个 ssh 代理来提供您的旧密钥?

按照“在终端上切换 Github 帐户时遇到问题”中的建议,添加以下行:

 IdentitiesOnly yes

到你的配置文件,看看 GitHub 是否还在使用那个旧的 id。

但是我仍然得到

 ssh: Could not resolve hostname github: nodename nor servname provided, or not known error

要解析的“ hostname”必须与Host配置文件的条目匹配。

如果该Host条目是 github-jononomo,那么您也必须在 ssh 地址中使用它:

git remote set-url origin github-jononomo:jononomo/.dotfiles.git
于 2012-10-26T18:31:49.397 回答