4

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.

2
  • 3
    ~/.ssh is not the same as /.ssh Commented Aug 1, 2011 at 19:08
  • 2
    open your Git bash and type echo $HOME. On my box (also running Win7), I get the path of my %USERPROFILE% and that's where my .ssh folder is. Commented Aug 1, 2011 at 19:17

5 Answers 5

8

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

Sign up to request clarification or add additional context in comments.

2 Comments

This is the correct answer! 1. set HOME inside your windows environment variables: question-defense.com/wp-content/uploads/2010/01/… 2. echo %HOME% inside console to see if it works...
By default your $HOME should be C:\Users\username I was able to set this temporarily in git bash via HOME=/c/Users/username. To set it permanently, go to start menu -> type "environment variables" (after pressing enter, it will bring up the Advanced tab in System Properties) -> click on Environment Variables in the bottom right to get to the window that @redaxmedia linked to. From there, you can add a new User variable, restart git bash, and your HOME should be permanently changed! (Win10)
3

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.

2 Comments

Okay, so using Git Bash I can access the /.ssh folder correctly, and my $HOME variable works- I made a new key and copied it to my GitHub but still no luck. What would be next?
You have to now add the new SSH key to your GitHub profile. See the instructions here: help.github.com/win-set-up-git under Step 4.
2

It looks like whatever git you're using can't figure out what your home directory is. Note the path: //.ssh/id_rsa. It should be /<your home directory>/.ssh/id_rsa. Check your HOME environment variable, and if this is cygwin, check over there about where your home dir is/should be.

Comments

0

In Windows 7 when you are asked "Enter file in which to save the key" use C:\Users\"username"\.ssh

Comments

0

Mark's answer tipped me off to why we were having this problem. We were running a DOS script that set a HOME environment variable. Changed that to have a different name and the issue when away.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.