2017-01-17 72 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

那麼你需要創建一個 –