2

I am currently trying to use git on windows using ssh. I generated a key (with ssh-keygen -t rsa) and added the public key to github. Unfortunately, everytime I connect the following appears:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'C:\\Users\\DaGeRe\\.ssh\\id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: C:\\Users\\DaGeRe\\.ssh\\id_rsa
Enter passphrase for C:\Users\DaGeRe\.ssh\id_rsa:

So, to get this working, I've done chmod 700 (like recommended in endless posts, for example SSH Private Key Permissions using Git GUI or ssh-keygen are too open ), and ls returns the following:

-rw-r--r--    1 DaGeRe   mkpasswd      951 May 20 10:59 id_rsa
-rw-r--r--    1 DaGeRe   mkpasswd      239 May 20 10:59 id_rsa.pub

But unfortunately, ssh-add C:\Users\DaGeRe.ssh\id_rsa or ssh -T git@github.com stillreturns the error. The chmod command does not seem to work, even chmod -c 700 id_rsa (like said here: https://superuser.com/questions/397288/using-cygwin-in-windows-8-chmod-600-does-not-work-as-expected) does not change anything.

Trying to remove all rights with windows (by the menues in settings) also does not work. After adding the User "Everyone" (German: "Jeder", the user may be called different in english windows) in Properties -> Safety (also translated by me from "Eigenschaften -> Sicherheit") and rejecting any access for him, the warning disappears.

With the first, empty passphrase-key, the following output came out of ssh-add:

C:\Users\DaGeRe\.ssh>ssh-add id_rsa
Enter passphrase for id_rsa:

And after this, nothing is displayed. But ssh-add -l also returns nothing:

C:\Users\DaGeRe\.ssh>ssh-add -l
The agent has no identities.

If I add an passphrase, it always says the passphrase is wrong, with the wrong rights (so the message from the beginning appears) and with the right rights (so no error appears, but it still says that the right phrase is wrong).

I am using OpenSSH 3.8.1 for windows and I don't have cygwin installed.

So somehow it seems to not be added, even if the rights are set correct. I'd be glad if anyone had an hint how to solve this problem.

This is the output of ssh -vT git@github.com

OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004                               
debug1: Reading configuration data /cygdrive/c/Users/DaGeRe/.ssh/config   
debug1: Applying options for github.com                                   
debug1: Reading configuration data /etc/ssh_config                        
debug1: Connecting to github.com [192.30.252.130] port 22.                
debug1: Connection established.                                           
debug1: identity file "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa" type -1      
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0 
debug1: no match: libssh-0.6.0                                            
debug1: Enabling compatibility mode for protocol 2.0                      
debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1                      
debug1: SSH2_MSG_KEXINIT sent                                             
debug1: SSH2_MSG_KEXINIT received                                         
debug1: kex: server->client aes128-cbc hmac-sha1 none                     
debug1: kex: client->server aes128-cbc hmac-sha1 none                     
debug1: sending SSH2_MSG_KEXDH_INIT                                       
debug1: expecting SSH2_MSG_KEXDH_REPLY                                    
debug1: Host 'github.com' is known and matches the RSA host key.          
debug1: Found key in /cygdrive/c/Users/DaGeRe/.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: "/cygdrive/c/Users/DaGeRe/.ssh/id_rsa"        
debug1: No more authentication methods to try.                            
Permission denied (publickey).  
Community
  • 1
  • 1
David Georg Reichelt
  • 963
  • 1
  • 15
  • 36
  • what was the exact chmod command you ran? Because after a correct chmod command, ls would show -rw------ not -rw-r--r-- – Chris Lear May 20 '14 at 09:33
  • This is probably what you need to do: cd .ssh, then chmod 700 * – Chris Lear May 20 '14 at 09:34
  • I've run chmod 700 id_rsa (in the correct folder), it seems like it works. If I do it with a not-existing file, it says "chmod: getting attributes of `asd': No such file or directory". But I have no clue why it hasn't set the rights right.. – David Georg Reichelt May 20 '14 at 09:41
  • What makes it seem like it works? If you do ls -l id_rsa straight afterwards, what does it show? – Chris Lear May 20 '14 at 09:50
  • It shows `-rw-r--r-- 1 DaGeRe mkpasswd 951 May 20 10:59 id_rsa`. I thought it would work, because if chmod can't find a file, it shows an error. `chmod -c 600 id_rsa` (like here: http://superuser.com/questions/397288/using-cygwin-in-windows-8-chmod-600-does-not-work-as-expected ) also returns nothing. What is maybe important, too: I have only OpenSSH and some comands installed, not the whole cygwin. – David Georg Reichelt May 20 '14 at 10:11
  • Maybe run your cmd shell as Administrator. You can probably type cmd in the "Run" box, then right-click the icon and go for "run as Administrator" - depending on your Windows version. – Chris Lear May 20 '14 at 10:19
  • Thanks for the hint, but unfortunately, this did not change anything. – David Georg Reichelt May 20 '14 at 13:18

1 Answers1

1

After some trying, I found a working workaround for that problem, using windows and running git: Use Putty instead of OpenSSH.

One has to set GIT_SSH to Plink (in my case SET GIT_SSH=C:\PortablePrograme\putty\PLINK.EXE) and start pagent as described here: http://guides.beanstalkapp.com/version-control/git-on-windows.html (If one has an ssh-key, that is already created and added to e.g. github, one can get this into the putty-format with conversions, instead of creating a new key).

I guess that this is only one possible solution to the problem, and I'll be glad to hear if anyone has another solution.

David Georg Reichelt
  • 963
  • 1
  • 15
  • 36