Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Can't Pull

Tags:

git

ssh

windows-7

First off, I should say I'm running Windows 7.

So I tried pulling from my repo earlier this morning like I usually do, and I wasn't able. I got the error:

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

To this, git's documentation says: Permission denied (publickkey)

Now, I'm not totally sure how to access the ~/.ssh folder since I'm on a Windows (can find anything online either) so I tried running ssh-keygen and just pressing enter. That didn't work either though.

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.

At this point, I tried searching for the error, but couldn't find any luck.

Can anyone help me restore my ability to pull from the repo again?

I suspect it may be a problem with PATH variables, since I accidently deleted them a few days ago and only restored what I could remember, but I'm not sure at all what's going on here.

EDIT: Using Git Bash, I navigated to ./ssh and made a new key.

Ceasar@BAUTISTC-PC ~ (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 Ceasar@BAUTISTC-PC

I then copied it over to https://github.com/account/ssh but still I'm getting an error:

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

Running ssh -vT [email protected] gives me:

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).

EDIT 2: So using Git Bash, I can pull successfully, which means this is something to do with Windows not knowing where the home directory is. Windows doesn't explicitly have a home variable though according to this: http://en.wikipedia.org/wiki/Environment_variable#Default_Values_on_Microsoft_Windows so I'm still a little confused.

like image 689
Ceasar Bautista Avatar asked Dec 09 '22 07:12

Ceasar Bautista


2 Answers

Manage your windows environment variable and add 'home' -> 'c:\users\your-win-account'. Restart your cmd-console.

like image 142
Mark Avatar answered Dec 25 '22 04:12

Mark


When it prompts you to "Enter file in which to save the key", don't use the default option. Instead input C:\Users\Ceaser\.ssh\id_rsa

This is assuming that you have the C:\Users\Ceaser\.ssh directory created. If not, first create it, then retry.

If using Git in Windows, though, I would recommend either using a GUI tool such as Git GUI or trying out cygwin.

like image 29
mattkelly Avatar answered Dec 25 '22 06:12

mattkelly