2016-12-03 112 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键。

相关问题