2017-01-17 73 views
1

我有GitHub帐户,我想推入本地存储库。我的密钥存储在〜/ .ssh/id_rsa_github路径中。路径〜/ .ssh/id_rsa已被用于其他目的。如何同步GitHub的rsa_key?

我通过:ssh-keygen生成密钥,然后将其保存在〜/ .ssh/id_rsa_github路径中,然后将其放在GitHub的SSH密钥选项卡中。

当我这样做:“混帐推-u起源大师,”我得到的错误:

The authenticity of host 'github.com (192.30.253.112)' can't be established. RSA key fingerprint is SHA256:****. Are you sure you want to continue connecting (yes/no)? Host key verification failed. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

我也试着键入:ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts,然后git push -u origin master并获得:

警告:永久添加已知主机列表中的IP地址“192.30.253.112”的RSA主机密钥。 权限被拒绝(公钥)。 致命:无法从远程存储库读取。

请确保您拥有正确的访问权限 并存在存储库。

你能帮我吗?

+0

尝试' ssh-keyscan -t rsa github.com >>〜/ .ssh/known_hosts' –

+0

但我想将github指向/.ssh/id_rsa_github – CrazySynthax

+0

'id_rsa_github'和'known_hosts'文件有不同的用途。您需要将github添加到您已知的主机列表中,以便建立连接 –

回答

0

尝试指定在你的ssh配置,你想使用另一种公钥对github上的,而不是默认id_rsa之一:

# ~/.ssh/config 
Host github-server 
Hostname github.com 
IdentityFile ~/.ssh/id_rsa_github 
IdentitiesOnly yes 

到存储库的链接也应该被更新:git remote set-url origin [email protected]:username/repo.git

+0

我没有这样的文件〜/ .ssh/config – CrazySynthax

+0

那么你需要创建一个 –