TDLR: For windows users,
- run
ssh-add "C:\\Users\\<your user>/.ssh/id_rsa"
- not
ssh-add ~/.ssh/id_rsa
For example I see this all the time:
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/User/.ssh/id_rsa:
Identity added: /c/Users/User/.ssh/id_rsa (/c/Users/User/.ssh/id_rsa)
$ git pull
Enter passphrase for key 'C:\Users\User/.ssh/id_rsa':
Note the inconsistent path separators: the ssh-agent converts ~ using Unix path separators, but git uses Windows path separators instead.
Given that the path of the id_rsa
file is used as key, this explains why the cache is missed.
- Another difference is
C:/
instead of /c/
- Related remark: When git asks you for the passphrase, it won't be cached, so you can be entering it there indefinitely. Try passing the phrase to
ssh-add
only.
- On Windows, assume that
~
is "multivalued", so it's best to be explicit.
ssh-add
looks at default locations like ~/.ssh/id_rsa
. On Windows, assume that's ambiguous. Explicitly pass in the explicitly formatted path instead of relying on default paths:
ssh-add "C:\\Users\\<your user>/.ssh/id_rsa"
, i.e. in @velval's answer too.