Of SSH, HTTPS, and GitLab
Pushing to GitLab with my SSH key stopped working a couple of months ago. Every now and then I tried to do a bit of troubleshooting but I didn’t manage to solve the problem… until today.
Another title for this post can easily be “Duhhhh!” But I’m getting ahead of myself. First some background.
At some point, which I associated with restoring my home folder after I head to restore some of my dotfiles, pushing to GitLab with my SSH key stopped working. No matter how many times I re-created my SSH keys, I was prompted for my username and password. To add to my bafflement, one day this also started happening with my Laptop, which up to that point worked fine with its SSH key pair.
Today in the morning, trying to troubleshoot this issue again and reading through the same articles again, I decided to post this problem to Mastodon. I was suggested to do a couple of things I tried before and things I haven’t, including checking if my SSH service was up and working (it was), and switching to ed25519 keys over RSA ones (I did). GitLab’s documents suggested that I check my SSH version is not too older (it isn’t).
It was kaushalmodi who finally cracked the case: “You mentioned ‘new disk’ or something like that earlier,” he posted. “Did you do git clone using the HTTPS URL on your new disk? If so, it set the remote URL to whatever you used to clone.”
I think I still have the red imprint of my hand on my forehead.
When I erased some of my folders, I also deleted my local repository. I had backups, but I wanted to make sure I’m exactly where my remote repository is pointing, so I cloned it. When I cloned it I used, you guessed it, the HTTPS link. The local git repository then configured the remote to the HTTPS link, not the ssh one (both are distinguished clearly on the GitLab page when viewing the repository).
The solution was simple: git remote set-url origin git@gitlab.com:taonaw/taonaw.git
. This post you’re reading now then is the first one in a couple of months that was uploaded with an SSH key, thanks to my techie friends at Mastodon. View the whole thread if you’d like.
Comments?
Reply to this post on Mastodon, or you can always email me: taonaw<at>protonmail<dot>ch (for GPG, click the lock icon on the navbar to the left).