Skip to content

Override that git clone SSH configuration

Posted in Storytime

Today I spent some time looking at a repository that I simply could not clone. It generally doesn’t happen and yet here I am writing about it. Let’s jump together into that short but intense git clone SSH configuration story.

More often the cause of such failure is an SSH key you forgot to set or something like that. To be fully transparent, it was the case here at first. However, after adding the ssh key, I still got the same damn error.

Now what? Well, I went to check the ssh key had the right format. Since I copied it through an echo command I figured I would delete the uploaded key then copy the original public key directly. Still nothing.

At this point, I decided to give up SSH cloning and to use the HTTP cloning function. Sure, I’ll have to enter my username and password but it’s a throwaway project it should be fine. Especially since my interactions with it will be limited.

So I go for it and error again!

What were the odds that around the time I left for a holiday such change would occur? Of course personal authorization token is better than password authentication but this is poor timing. What makes it worse is that I hadn’t used a personal authorization token for source control ever and hadn’t used password authentication for a couple of years. So I decided to attempt making SSH cloning work once more.

This is where I pulled my joker card, searching for the answer on StackOverflow. Interestingly enough the answer comment highlighted what I already knew. When you do not specify the ssh key to use, git will use id_rsa. However, it did not in my case. But the command linked to the answer was the key.

Here is the full command from the answer:

git clone git@provider.com:userName/projectName.git --config core.sshCommand="ssh -i ~/location/to/private_ssh_key"

This clone command overrides the ssh command ran to identify the user with another ssh command. There you can specify which command you want to run with which parameters and more importantly, where the private key is.

Now you know, when you what to do when you face any issue with your SSH keys. First, make sure you uploaded your public key correctly. Second, try overriding the git clone SSH configuration either through a local config file or with the command above. Lastly, if none of this work, retire.

Thank you for reading, I will see you next time! In the meantime don’t hesitate to check out my gaming videos on Rumble!

Cover by Buse Doa from Pexels.

Be First to Comment

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    %d bloggers like this: