Search code examples
gitcommand-promptssh-agentgit-for-windows

How can I enter my passphrase only once in Git CMD?


After installing Git for Windows, I am using Git CMD (not Git Bash). I have a passphrase-protected private key stored at %USERPROFILE%/.ssh/id_rsa

I am running a script that performs Git actions on multiple repos. Every time it interacts with a new repo I have to enter my passphrase again.

Is there any way I can enter my passphrase only once (kind of like Pageant)?


Solution

  • Yes you can do this. After you launch Git CMD run

    start-ssh-agent
    

    You will be prompted for your passphrase, and the ssh-agent will store your private key for future use (you can find the ssh-agent.exe process in your Task Manager).

    Any Git commands that are used after that will access your private key via ssh-agent, until the end of your desktop session.