Search code examples
gitpowershellsshssh-agentposh-git

When pushing to github, why am I always asked for my ssh password?


Some facts:

  • I'm on Windows 10
  • I'm using Power Shell with PoshGit (I don't want to use the cygwin bash shell or any derivative thereof)
  • My repositories are all git@..., i.e. they don't use https remotes
  • When I start a new shell session, if not already running, ssh-agent starts up and prompts me for my password, then stays resident for subsequent sessions
  • I have confirmed that ssh-agent is running in the background
  • my id_rsa file is present in the list of saved identities (ssh-add -l) and that is the key file I'm prompted to enter a password for when connecting to a github repository
  • I've also tried github's help page suggestion, specifically: git config --global credential.helper wincred - it didn't do anything.

Not one tutorial or bit of advice I've been able to find has been able to stop ssh from asking for my password every time I push/pull/etc.

Any help would be appreciated.

Edit

For context, Scott Haack's old article about how this is supposed to work (though apparently not for me): http://haacked.com/archive/2011/12/19/get-git-for-windows.aspx/

Edit

ssh -vvvT git@github.com verify generates this (relevant snippet):

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007                 
debug1: Reading configuration data /etc/ssh/ssh_config    
debug2: ssh_connect: needpriv 0                           
debug1: Connecting to github.com [192.30.252.130] port 22.
debug1: Connection established.                           
debug1: identity file /c/Users/xxxxx/.ssh/identity type -1
debug3: Not a RSA1 key file /c/Users/xxxxx/.ssh/id_rsa.   
debug2: key_type_from_name: unknown key type '-----BEGIN' 
debug3: key_read: missing keytype                         
debug2: key_type_from_name: unknown key type 'Proc-Type:' 
debug3: key_read: missing keytype                         
debug2: key_type_from_name: unknown key type 'DEK-Info:'  

I removed and readded my key file and was prompted for a password:

D:\> ssh-add -D 
All identities removed.
D:\> ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/xxxxx/.ssh/id_rsa:
Identity added: /c/Users/xxxxx/.ssh/id_rsa (/c/Users/xxxxx/.ssh/id_rsa)
D:\> ssh-add -l 
2048 05:d5:8f:f8:e5:41:66:90:4c:a1:03:93:9d:e5:18:10 /c/Users/xxxxx/.ssh/id_rsa (RSA)

Private key file looks like this (private details removed, obviously):

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,xxxxxxxxxxxxxxxx

............etc.==
-----END RSA PRIVATE KEY-----

No idea why it's adding it one way and then getting confused when it tries to read it back.

Edit

As per comments and the accepted answer, my PATH pointed at a very outdated bin folder containing the ssh-agent and ssh-add that I was using (not to mention keygen). Fixing that, generating a new key, and pointing PATH at the correct, updated git bin folder has solved the problem.


Solution

  • Some guides point out to the really old version of openssh (yes, current version is 7.1p1):

    OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007

    And the key looks also really ancient (I hope nobody is using DES in production anymore):

    DEK-Info: DES-EDE3-CBC,xxxxxxxxxxxxxxxx

    Make sure you have something more recent in your PATH.