also works for Git Bash and Cygwin users on Windows
-
Be sure to have a recent version of Windows 10 (>=
Windows 10 1809
) -
Install
- KeePass: a cross-platform password manager
- KeeAgent: a plugin for KeePass allowing you store (encrypted) SSH keys in the database and expose them to software that needs it (e.g. Git, SVN). In more technical terms, KeeAgent exposes an SSH agent.
If you use Chocolatey, the package manager for Windows, simply type:
choco install -y keepass keepass-plugin-keeagent
-
Configure KeeAgent to use OpenSSH: open KeePass, go to
Tools -> Options -> KeeAgent
and tickEnable agent for Windows OpenSSH (experimental)
-
Configure Git to use OpenSSH:
git config --global core.sshcommand "C:/Windows/System32/OpenSSH/ssh.exe"
-
If you use SVN: set the environment variable
SVN_SSH
toC:/Windows/System32/OpenSSH/ssh.exe
as well.
If you perform the latter two steps from within Git Bash (or Cygwin), you will be able to use your SSH keys from within there, too!
You are ready to go!
- Add your SSH private key to KeePass
- Just use
git
,svn
,ssh [email protected]
as you would usually do. Enjoy!
git push
hangs when pushing repos with Git LFS contents. For them, I'd recommend resorting to the previous approach (which I used for years):
-
configure KeePass and KeeAgent as above
-
install Kitty, a maintained successor of Putty:
choco install kitty
-
for every affected repo, do once:
- copy your remote from
git remote -v
(e.g.[email protected]:my_group/my_repo.git
) - run
C:/ProgramData/chocolatey/bin/PLINK.exe <your remote>
, verify the host's fingerprint, and accept git config core.sshcommand "C:/ProgramData/chocolatey/bin/PLINK.exe"
git push
can now be run as usual
The step with running
PLINK.exe
once manually is necessary because otherwise the confirmation question for the host's fingerprint will appear duringgit push
, where you cannot answer it apparently (due to some terminal/shell boundary issues?). - copy your remote from
Credits to Bratkartoffel (German forum) for suggesting to use KeeAgent.
ComFreek, reminder to self: if you change this Gist's URI, also change it in the two posts at https://www.tutorials.de/threads/ssh-keys-sinnvoll-unter-windows-git-bash-nutzen.405127/ that reference it.