Git:Adding 添加第二个 github 帐户时出错 "ssh: Could not resolve hostname github-secondUser"

Git:Adding error adding a second github account "ssh: Could not resolve hostname github-secondUser"

我正在按照有关如何添加第二个 github 帐户的 video 的说明进行操作。但我收到此错误:

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.

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

非常感谢你的帮助。

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

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

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