Github用户名错误

发布于 2024-12-15 17:59:48 字数 895 浏览 2 评论 0原文

当我运行此命令时,我已经使用 guthub 在这台计算机上设置了一个名为 myaccount 的先前 github 帐户

ssh -T [email protected]
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access.

好的,但我现在已经设置了一个名为 samaccount 的新 github 帐户,但我无法运行此命令,但出现此错误。

git push -u origin master

我收到此错误

ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount.

我不希望它使用 myaccount 它应该使用 samaccount !

我已遵循此处的所有步骤 http://help.github.com/mac-set -up-git/ 设置全新的 ssh 密钥。

并且还多次运行此命令

git config --global user.name "samaccount"

,但它仍然使用 myaccount 它太烦人了我哪里出错了???

I have setup with guthub with a previous github account on this computer called myaccount when i run this command

ssh -T [email protected]
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access.

Ok but i have now setup a new github account called samaccount but i cant run this command i get this error.

git push -u origin master

i get this error

ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount.

I dont want it to use myaccount it should be using samaccount !!!

i have followed all the steps here http://help.github.com/mac-set-up-git/
setup brand new ssh key.

and also run this command many times

git config --global user.name "samaccount"

but it still uses myaccount its sooo annoying where am i going wrong???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2024-12-22 17:59:48

GitHub 会将您识别为 myaccount,因为 SSH 使用的密钥与已添加到 GitHub 网站上的 myaccount 帐户的公钥相对应。

如果您想完全切换为使用 sameueleast 帐户而不是 myaccount,您可以执行以下操作:

  • myaccount 身份登录 GitHub 网站
  • 转至“帐户设置”
  • 转到“SSH 公钥”
  • 从该列表中删除您的公钥
  • 注销 以 samueleast身份
  • 登录 GitHub 网站
  • 转到“帐户设置” -> > “SSH 公钥”
  • 选择“添加另一个公钥”并粘贴您的公钥内容。您的公钥(可能)将被称为 id_rsa.pubid_dsa.pub 并位于您的 .ssh 目录中。

另一方面,如果您希望在推送到 GitHub 时能够使用 myaccountsamueleast,则需要为 [email protected] in ~/.ssh/config,例如:

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

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

假设您已生成第二个 SSH 密钥对并且给他们起了上面的名字。然后,您需要确保在 git 远程 URL 中使用适当的别名。例如,如果您想更改 origin 遥控器,以便推送到 origin 意味着“推送到 origin as samueleast”,您可以执行以下操作:

 git remote set-url origin \
     git@github-samueleast:samueleast/Samuel-East-S3-Audio-Playlist-Player.git

GitHub recognizes you as myaccount because SSH is using a key that corresponds to a public key that has been added to the myaccount account on the GitHub website.

If you want to switch entirely to using the sameueleast account instead of myaccount, you can do the following:

  • Login to GitHub's website as myaccount
  • Go to "Account Settings"
  • Go to "SSH Public Keys"
  • Delete your public key from that list
  • Logout
  • Login to GitHub's website as samueleast
  • Go to "Account Settings" -> "SSH Public Keys"
  • Select "Add another public key" and paste in the contents of your public key. You public key will (probably) be called id_rsa.pub or id_dsa.pub and be in your .ssh directory.

On the other hand, if you want to be able to use either myaccount or samueleast when pushing to GitHub, you will need to create aliases for [email protected] in ~/.ssh/config, such as:

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

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

That assumes you've generated a second SSH keypair and given them names as above. Then you need to make sure that you are using the appropriate alias in the URLs of your git remotes. For example, if you want to change your origin remote so that pushing to origin means "pushing to origin as samueleast", you could do:

 git remote set-url origin \
     git@github-samueleast:samueleast/Samuel-East-S3-Audio-Playlist-Player.git
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文