(GitLab specifically! (No issues with GitHub))
I'm trying to create a script to pull a project from main GitLab branch without asking for password. A couple of remote computers have a kiosk-mode project. It's kind of boring to always connect manually to them - instead of having a cron-job to pull automagically.
I've setup to use SSH and created and added my SSH ed25519 key.
Added the proper url in ./.git/config like:
[remote "origin"]
url = [email protected]:<ME>/<REPO>.git
where <ME> and <REPO> are my username and repository :)
Using git pull or fetch always asks for password. The same does not happens on my GitHub repos.
The only way I managed to make it work was using a Personal Access Token like:
[remote "origin"]
url = https://oauth2:<MY P. A. TOKEN>@gitlab.com/<ME>/<REPO>.git
But I don't like the token being in plaintext and having to do stuff out of the scope of SSH handshakes.
Is there something GitLab-specific I'm missing? Every help-page I was able to search just talks about setting the correct SSH URI ([email protected]..... etc) which I already did. But every time I trigger a git pull it keeps asking for password.
Windows. Git Bash.
Appreciate any help, trick or insight.
I've just solved this problem for my gitlab.com repos: I've just followed the steps in their tutorial at Use SSH keys to communicate with GitLab.
There they explain how to create keys, but since mine already existed all I had to do was to follow the steps in the section Configure SSH to point to a different directory. They're only:
Type the commands
eval $(ssh-agent -s)
ssh-add <full path to private SSH key>
In Linux, the SSH keys are usually saved in the folder ~/.ssh/
Edit the ~/.ssh/config file to have the lines
Host gitlab.com
PreferredAuthentications publickey
IdentityFile <full path to private SSH key>
I had the same problem on Windows, even the ssh -T [email protected] didn't work! The solution was a lot simpler that I thought: I had to open git bash as an administrator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With