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 [email protected]
Enter passphrase for key 'C:\Users\[username]/.ssh/id_ed25519':
Welcome to GitLab, @000[...]!
I also used
>git remote set-url origin [email protected]:000[...]/project.git
without errors. However, when I try to commit and push to the repository, then Git asks for the Password of [email protected]
and not for the passphrase of the SSH key.
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
CodePudding user response:
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"
CodePudding user response:
in PyCharm try navigating to VCS -> Git -> Remotes
and make sure that the URL configured there is aligned with the SSH URL (u can see the ssh URL when navigating to the repo via the browser and clicking on the clone button)