Friday, June 5, 2020

Using git with ssh keys from the regular Windows command prompt without git bash

Install git for windows with all the defaults.

Create an ssh key if you don't already have one using ssh-keygen. Let's name it id_rsa_user.

Add the public key (id_rsa_user.pub) to your git service - bitbucket, gitlab, github, etc.

Enable the ssh-agent service in windows.





I've set mine to automatic - delayed start.

Move the your private key (id_rsa_user) to c:\users\<user>\.ssh

In the same folder, create a file called config with no extension. Populate it with the following:

Host gitlab.com
    HostName gitlab.com
    User git
    IdentityFile /c/Users/<user>/.ssh/id_rsa_user

Change your git service hostname as appropriate.

ssh push should now work.