Load pubkey "/c/Users/xxx/.ssh/id_rsa": invalid format

i have keys, and use them successfully. today i created a new repo, and only for this one,
with any git command i get this nasty message:
git clone git@gitlab.com:username/reponame.git store
Cloning into ‘store’…
load pubkey “/c/Users/username/.ssh/id_rsa”: invalid format
Load key “/c/Users/username/.ssh/id_rsa”: invalid format
git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What could be the reason?
just for testing, went to some other repo on gitlab, everything works. commit, push, pull…
mystery.

Assumption - On Windows.
Short answer - use a new SSH key.

Tip - Start from the first weird message. Or error or diagnostic or whatever it is named in a ad hoc manner in this particular instance.


“/c/Users/username/.ssh/id_rsa”

This is just a hunch at this point. There are other problems that you will run into. Look around and you will figure out a simple way to avoid them.

Shave a couple of useless months off your life. Use them for better stuff. :smile_cat:

Or don’t. Your choice. No pressure.

Heya @ronalmog and welcome to Gitlab community.

load pubkey “/c/Users/username/.ssh/id_rsa” did you double check if you have an actual pub key which should be in .ssh/id_rsa.pub with proper permissions?

What happens when you run git clone https://gitlab.com/username/reponame store instead of git clone git@gitlab.com:username/reponame.git store ?

Thanks @alhemicar!
So I do have in that location id_rsa and id_rsa.ppk, but they are probably bad, from previous attempt.
(i made them with puttygen, it didn’t work, gitlab did not accept it)
The correct pair (i created using git bash) has different names: git-lab, and git-lab.pub
the .pub is uploaded to gitlab and it works well for all other repos.
just this one is looking for id_rsa, which is there, but we know it’s bad.
how do i tell it to use the correct key?

more answers to @alhemicar:
when i try this:
git clone https://gitlab.com/username/reponame.git , it works!
why did i even try with git@gitlab… ? just because that is written in the ‘command line instructions’ after you create an empty repo.
so basically it is solved. all i have to do is use the right command.

1 Like

That should work for you .

In case it keeps happening for future repos or you want to try and fix this issue properly you should make sure that your ssh config was set correctly in ~/.ssh/config (if you have the config) and it’s pointing the path to the working set of keys.

Alternatively add the working ssh file using ssh-add .

run: ssh-add <PATH-TO-SSH-FILE>

example: ssh-add ~/.ssh/gitlab_rsa

Some of the info i mentioned here I found from gitlab source regarding ssh keys.

1 Like

great stuff. thank you!!

No problem. Good luck :slight_smile:

So all you wanted to do was clone the repository. And now you have done that without any problems.

Great. :smile_cat:

I assume you did replace that key and use openssh for ssh. So it’s all good!