Publickey stopped working on one repository

David Hough
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 18, 2022

This evening I pushed some commits to a repo using SourceTree, which worked just fine. A short time later, I tried pushing some more and suddenly the publickey decided not to work, asking for a password and then telling me that passwords were now disabled. If I check with ssh -T, it assures me that the key is just fine, and if I try pushing something to another repo, that works also, so it's nothing to do with the key itself. I tried restarting SourceTree, which prompted for my master key as expected, but it still refused to push to the repo. I tried the WSL command line and that also failed. I tried TortoiseGit and that failed, but again, just for the one repository.

I was helping one of my colleagues a few days ago who had a similar problem, and it mysteriously started working again for him after a while, but I've not been lucky with that yet.

I just tried a pull from the repository and it won't let me do that either, but once again, other repos are just fine.

I can view the repository and its files on the web just fine.

Edit to add: it's some sort of local repository corruption. I was able to clone the repository  to a new directory OK, copy the modified files from the previous one, commit and push.

1 answer

1 accepted

0 votes
Answer accepted
David Hough
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 19, 2022

I seem to have figured out a solution, even though I don't know why it broke, but in case it helps someone else, this is what appears to have happened:

Go look at the git config (.git/config) file and under remote origin, it will have 

url = https://....
fetch = +refs/heads/*:refs/remotes/origin/*

and no mention of an ssh key. 

What you need there is 

url = git@bitbucket.org:...
fetch = +refs/heads/*:refs/remotes/origin/*
puttykeyfile = ...

The quickest way to fix it seems to be to clone the repository to somewhere else and copy over the config file from the new one to the old one, or at least copy the remote section.

Another variation reported by a colleague appears to be where the url is correct but the line defining the key file is missing.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events