Search code examples
git-bashssh-agent

Git Bash asks for SSH passphrase on first run after every PC reboot


Every time I start up Git Bash after restarting my Windows 10 PC it asks me for the passphrase for my SSH key.

I didn't used to have this problem, and I've never seen it anywhere else; I use Git Bash at work and have never seen this problem there.

Initializing new SSH agent...
succeeded
Enter passphrase for /c/Users/User/.ssh/id_rsa:

If I close the Git Bash window and open a new one, the new window doesn't prompt me for a passphrase. Nor will any subsequent window. It doesn't seem to matter whether I enter a passphrase in the first window or not.

However, if I restart, the first Git Bash window will again prompt me for a passphrase.

I've tried uninstalling and reinstalling Git. I've also tried running ssh-add -k path/to/key. Neither approach worked.


Solution

  • If I close the Git Bash window and open a new one, the new window doesn't prompt me for a passphrase.

    That is because your ~/.bashrc (under %USERPROFILE%) must have launched the ssh-agent, which will cache your passphrase for the time of your Windows session.
    But when restarting Windows, you will need to enter the passphrase again.