0

I'm using the ubuntu bash (subsystem) on windows 10 as my shell. I have a gitlab git repository that I cloned. When I use the git from this shell it is separate from my windows git and I'm unable to make it use my SSH key. It just keeps asking for my user/pass. Note that the SSH key is configured correctly in gitlab.

I place my id_rsa and id_rsa.pub in ~/.ssh/ (ubuntu subsystem path)

Any idea?

  • start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work. – xaa Nov 28 '18 at 16:06
  • @xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass. – chef Nov 29 '18 at 9:21
0

OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.

To view current remotes: git remote -v

To switch a remote: git remote set-url origin git@gitlab.com:XXXXX

-1

Use this command:

ssh-copy-id username@server.domain.com

Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.

  • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used. – chef Nov 28 '18 at 14:38
  • Thanks @davidbaumann ! Next time I'll be more accurate! – Peredat0r Nov 28 '18 at 14:38
  • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out. – Peredat0r Nov 28 '18 at 14:42
  • you can also add -v, so it will show you the authentication methods it's trying. – davidbaumann Nov 28 '18 at 15:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.