Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Git does not use SSH key (Windows)

I created a SSH key for my GitLab repository and when I test it with SSH it does work and asks for the passphrase:

>ssh -T git@gitlab.lrz.de
Enter passphrase for key 'C:\Users\[username]/.ssh/id_ed25519':
Welcome to GitLab, @000[...]!

I also used

>git remote set-url origin git@gitlab.lrz.de:000[...]/project.git

without errors. However, when I try to commit and push to the repository, then Git asks for the Password of git@gitlab.lrz.de and not for the passphrase of the SSH key.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

According to the Docs (https://docs.gitlab.com/ee/ssh/), you can set the ssh key in the config file ~/.ssh/config. So I created a text file in this directory with this content:

Host gitlab.lrz.de
 HostName gitlab.lrz.de
 IdentityFile ~/.ssh/id_ed25519

It still does not work and I am not sure if it even uses this config file. I was able to get everything running on a Linux server but not on this Windows computer. I tried it via command line and via Pycharm.

>git --version
git version 2.35.1.windows.1 

>Solution :

You can customize the ssh command used by git in the git config and then pass your key when using any git command.

git config core.sshCommand "ssh -i ~/.ssh/id_ed25519"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading