public 密钥不适用于新笔记本电脑连接到 github

public key not working for a new laptop to connect to github

我正在尝试为我的新笔记本电脑添加一个新的 ssh 密钥,但是在添加之后,它总是因为 public 密钥问题而被拒绝,有人有任何解决问题的想法吗?我在这里遵循确切的指南=> https://help.github.com/articles/generating-an-ssh-key/

ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address 'xxx.xx.xxx.xxx' to the list of known hosts.
Permission denied (publickey).

尝试使用 ssh-keygen -R github.com,仍然无法正常工作,

$ ssh-keygen -R github.com
# Host github.com found: line 10 type RSA
/Users/xxx/.ssh/known_hosts updated.
Original contents retained as /Users/xxx/.ssh/known_hosts.old
$ ssh -T git@github.com
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is (skip fingerprint details here).
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
Permission denied (publickey).

此致, 林

您可以设置多个 github 身份。甚至在 on several places.

中也有描述

基本思路是在 ~/.ssh/config 中创建两个别名:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_work

Host github.com-the-other
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_the-other

然后将 .git/config 中的 urlgithub.com togithub.com-the-other` 更改。该行将如下所示:

[remote "origin"]
    url = git@github.com-the-other:the-other/gfs.git