【问题标题】:Git:Adding error adding a second github account "ssh: Could not resolve hostname github-secondUser"Git:添加错误添加第二个 github 帐户“ssh:无法解析主机名 github-secondUser”
【发布时间】:2018-06-28 02:01:37
【问题描述】:

我正在按照video 的说明添加第二个 github 帐户。但我收到了这个错误:

ssh: Could not resolve hostname github-secondAccount: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

这就是我所做的。

我添加了第二个 sshkey:

id_rsa
id_rsa.pub
id_rsa_secondAccount
id_rsa_secondAccount.pub

并且还创建了一个配置:

#first account
        Host github.com
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa

#secondAccount account
        Host github-secondAccount
        HostName github.com
        User git
        IdentityFile id_rsa_secondAccount


echo "# myNewRepo" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github-secondAccount:myUSer/myNewRepo.git
git push -u origin master

但在git push -u origin master 的那一刻,我收到了这个错误:

ssh: Could not resolve hostname github-secondAccount: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

你们中的任何人都知道我做错了什么或如何解决这个问题?

非常感谢您的帮助。

【问题讨论】:

    标签: git github git-svn


    【解决方案1】:

    网址应该是github-secondAccount:myUser/myNewRepo.git(不需要git@

    确保您的 ~/.ssh/config 文件被保护为 600。
    第二个IdentityFile 应该是~/.ssh/id_rsa_secondAccount

    最后,确保id_rsa_secondAccount.pub(公钥)已发布到myUser SSH 密钥设置页面。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 1970-01-01
    • 2018-12-15
    • 2022-10-01
    • 1970-01-01
    • 2020-02-18
    相关资源
    最近更新 更多