gitsshbitbucketgit-bashtortoisegit

Bitbucket: Getting "No supported authentication methods available (server sent: publickey)" when using with ssh keys


I know there's many similar questions like this out there already, but so far I couldn't find any describing or adressing/ resolving my exact issue yet.

I've just setup my personal ssh key in Bitbucket by using the following command:

ssh-keygen -t ed25519 -C "${myMail}

and it successfully created id_ed25519.pub and id_ed25519 in my %USERPROFILE%\.ssh directory.

The public key I've copied and pasted to Bitbucket as per official documentation like follows:

clip < id_ed25519.pub

When having tried to clone the repository via TortoiseGit like so:

ssh://git@${repoUrl}:${sshPort}/${pathToProject}.git

I got the following error:

No supported authentication methods available (server sent: publickey)

*Note: I accepted the server keys/ fingerprint, since cloning from this server for the first time.

Additional output from TortoiseGit:

git.exe clone --progress -v "ssh://git@${repoUrl}:${sshPort}/${pathToProject}.git" "C:\${targetLocationPath}"
Cloning into 'C:\${targetLocationPath}'...
fatal: Could not read from remote repository.

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


git did not exit cleanly (exit code 128) (4625 ms @ 03.03.2024 11:54:51)

Also removing the ssh:// part from the clone url (as suggested here) didn't help - here the request simply timed out.

After attempting to clone the repository directly via the CLI via Git Bash it worked successfully without issues (I needed to accept the server key/ fingerprint during the process again though):

$ git clone ssh://git@${repoUrl}:${sshPort}/${pathToProject}.git "${targetLocationPath}"
Cloning into '${targetLocationPath}'...
The authenticity of host '[${host}]:${sshPort} ([${ipAddress}]:${sshPort})' can't be established.
RSA key fingerprint is SHA256:${fingerprint}.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[${host}]:${sshPort}' (RSA) to the list of known hosts.
...

=> What am I missing in the setup or what else do I need to check/ configure to get it also working with TortoiseGit now? Shouldn't both tools use the same "subsystems" and ssh keys to access the repo? -> How can I check and verify that?

As of now it still is working directly via Git Bash only, but not in TortoiseGit. They keys themselves obviously are not the problem and work fine.

Tools used:

PS: It was a newly setup Windows 10, therefore setting up the machine and cloning the repository for the first time ever.

EDIT:

After searching a bit more I found out about the ssh-agent service. I then found following related posts about different ssh implementations/ agents being used, which may lead to a solution for this:


Solution

  • As suspected there where different "subsystems" (-> ssh implementations/ agents/ clients) in use.

    For me the current fix will be to change the ssh client used by TortoiseGit to the one used and provided by Git as well from: "C:\Program Files\Git\usr\bin\ssh.exe".

    This you can do in TortoiseGit -> Settings -> Network and then in the SSH section.

    I chose the OpenSSH client provided by Git to keep the config between the CLI and TortoiseGit more similar rather than chosing the one from Windows.

    --

    By default TortoiseGit is using the PLink/ TortoiseGitPlink (-> "C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe") client whereby Windows/ Git (CLI) use OpenSSH.

    => Note: Windows uses it's own OpenSSH client from e.g. "C:\Windows\System32\OpenSSH\ssh.exe", but Git also brings it's own ssh client e.g. in "C:\Program Files\Git\usr\bin\ssh.exe".

    --

    Great resources to go deeper on this are the following:

    Thanks MrTux for pointing it out and the support!