2016-12-03 38 views
1

我已經爲Windows設置了GitHub並使用它來創建與我的帳戶相關聯的SSH密鑰。我可以在GitHub上的Windows GUI執行git的操作,但是當我嘗試運行命令在命令提示符像git clone [email protected]:whatever.git我得到一個錯誤這樣的:命令行Git無法識別使用GitHub for Windows生成的密鑰

C:\Users\Nat\Documents\GitHub>git clone [email protected]:natdempk/whatever.git 
Cloning into 'whatever'... 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

爲什麼會出現這種情況時,一切從GitHub的工作對於Windows GUI?

回答

2

當GitHub for Windows創建密鑰時,它們被命名爲github_rsagithub_rsa.pubgit預計密鑰默認命名爲id_rsaid_rsa.pub,所以它不會從GitHub for Windows中找到密鑰,並會給你Permission denied (publickey)。爲了解決這個問題,你應該創建github.comC:\users\<username>\.ssh\config一個SSH的配置文件看起來像下面這樣:

Host github.com 
    HostName github.com 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/github_rsa 

此通知git進行連接到github.com操作時,使用生成的GitHub的Windows鍵。

相關問題