【问题标题】:SSH check to Github resolves to GitlabSSH 检查到 Github 解析到 Gitlab
【发布时间】:2020-07-09 03:06:05
【问题描述】:

挑战:

我目前正在设置对我的 Github 帐户的 SSH 访问,并按照此处https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh 突出显示的说明进行操作后,我尝试测试连接。这导致我运行ssh git@github.com 命令,如下面的屏幕截图所示。 我不明白为什么连接会解析到 Gitlab

itunuloluwa@MacBook-Pro .ssh % ssh -T git@github.com
Welcome to GitLab, @ifatoki!

Error Screenshot

上下文:

  • 这是一个新的 Macbook pro,我从之前为 Github 和 Gitlab 设置 SSH 的那个迁移了我的所有设置。因此,这些键现在存在于这个 mac 中。
  • 因此,我从我的 Gitlab 帐户中删除了密钥,但是当我仍然运行检查时,它解决了(这很奇怪)

【问题讨论】:

  • 感谢@snakecharmerb,由于当时对 StackOverflow 进行的一些维护阻止了编辑,我无法立即回复。

标签: github ssh gitlab


【解决方案1】:

所以我做了一些挖掘,发现挑战在于我的配置文件~/.ssh/config。 它的形式是

HostName gitlab.com
  AddKeysToAgent yes
  UseKeychain yes
  ForwardAgent yes
  IdentityFile ~/.ssh/gitlab_id_rsa

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

只需像下面这样修改它即可解决问题

Host gitlab
  HostName gitlab.com
  AddKeysToAgent yes
  UseKeychain yes
  ForwardAgent yes
  IdentityFile ~/.ssh/gitlab_id_rsa

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-17
    • 2015-07-27
    • 1970-01-01
    • 2022-06-24
    • 2016-12-30
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多