2011-08-01 75 views
3

首先,我應該說我運行Windows 7的Git:不能拉

所以,我想從我的回購在今天上午早些時候拉像我平時做的,我是不能夠。我得到的錯誤:

The authenticity of host 'github.com (207.97.227.239)' can't be established. 
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. 
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of know 
n hosts. 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 

對此,git's documentation說: Permission denied (publickkey)

現在,我不完全知道如何因爲我訪問在Windows中的〜/ .ssh文件夾(可在網上找到任何東西),所以我試着運行ssh-keygen,然後按回車。那雖然不起作用。

C:\Users\Ceasar\Desktop\lemonwi.se\lw_reviews\src>ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (//.ssh/id_rsa): 
Could not create directory '//.ssh'. 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
open //.ssh/id_rsa failed: No such host or network path. 
Saving the key failed: //.ssh/id_rsa. 

在這一點上,我試圖尋找錯誤,但找不到任何運氣。

任何人都可以幫助我恢復我從再次回購的能力嗎?

我懷疑它可能是一個PATH變量的問題,因爲我幾天前意外刪除了它們,只是恢復了我能記住的內容,但我不確定這裏發生了什麼。

編輯:使用Git Bash,我導航到./ssh並創建了一個新的密鑰。

[email protected] ~ (master) 
$ ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (/c/Users/Ceasar/.ssh/id_rsa): 
/c/Users/Ceasar/.ssh/id_rsa already exists. 
Overwrite (y/n)? y 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /c/Users/Ceasar/.ssh/id_rsa. 
Your public key has been saved in /c/Users/Ceasar/.ssh/id_rsa.pub. 
The key fingerprint is: 
10:b5:03:59:ec:02:18:fd:90:3c:69:1e:02:a4:93:2d [email protected] 

我然後複製它交給https://github.com/account/ssh,但我依然收到錯誤:

C:\Users\Ceasar\Desktop>git pull origin master 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 

運行SSH -vT [email protected]給我:

C:\Users\Ceasar\Desktop>ssh -vT [email protected] 
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007 
debug1: Connecting to github.com [207.97.227.239] port 22. 
debug1: Connection established. 
debug1: identity file /.ssh/identity type -1 
debug1: identity file /.ssh/id_rsa type -1 
debug1: identity file /.ssh/id_dsa type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debia 
n-5github2 
debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_4.6 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-cbc hmac-md5 none 
debug1: kex: client->server aes128-cbc hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Host 'github.com' is known and matches the RSA host key. 
debug1: Found key in /.ssh/known_hosts:1 
debug1: ssh_rsa_verify: signature correct 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: /.ssh/identity 
debug1: Trying private key: /.ssh/id_rsa 
debug1: Trying private key: /.ssh/id_dsa 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

編輯2:所以使用Git Bash,我可以成功取出,這意味着這與Windows不知道主目錄的位置有關。 Windows沒有顯式地有一個家庭變量,雖然根據這個:http://en.wikipedia.org/wiki/Environment_variable#Default_Values_on_Microsoft_Windows,所以我仍然有點困惑。

+3

'〜/ .ssh'是不一樣的'/ .ssh' – titaniumdecoy

+1

打開你的Git bash和鍵入'回聲$ HOME'。在我的盒子(也運行Win7的),我得到了我'%USERPROFILE%'路徑而這也正是我的'.ssh'文件夾。 – eckes

回答

2

它看起來像你使用的任何混帳都無法弄清楚你的主目錄是什麼。請注意路徑://.ssh/id_rsa。它應該是/<your home directory>/.ssh/id_rsa。檢查你的HOME環境變量,如果這是cygwin,請檢查你的家庭目錄是/應該在哪裏。

3

當它提示您「輸入要保存密鑰的文件」時,請勿使用默認選項。而是輸入C:\ Users \ Ceaser \ .ssh \ id_rsa

這是假定您已創建C:\ Users \ Ceaser \ .ssh目錄。如果沒有,首先創建它,然後重試。

如果在Windows中使用Git,我會推薦使用GUI工具,如Git GUI或嘗試cygwin

+0

好了,所以使用Git猛砸我可以正確訪問/.ss​​h文件夾,我的$ HOME變量工程─我做了一個新的密鑰並將其複製到我的GitHub但仍沒有運氣。接下來會是什麼? –

+0

您現在必須將新的SSH密鑰添加到您的GitHub配置文件中。見說明書在這裏:http://help.github.com/win-set-up-git/在步驟4 – mattkelly

8

管理你的Windows環境變量並添加'home' - >'c:\ users \ your-win-account'。 重新啓動cmd控制檯。

+0

這是正確的答案! 1.在你的windows環境變量裏設置HOME:http://www.question-defense.com/wp-content/uploads/2010/01/windows-7-environment-variables.gif 2. echo%HOME %內部控制檯,看看它是否工作... – redaxmedia

0

在Windows 7中,當您詢問「輸入要保存密鑰的文件」時,請使用C:\ Users \「username」\。SSH

0

馬克的回答放倒我了,爲什麼我們有這個問題。我們正在運行一個DOS腳本,它設置了一個HOME環境變量。改變了這一點,以便在離開時擁有不同的名稱和問題。