FATAL ERROR: No supported authentication methods available (server sent: publickey)
Asked by Daiki Haraguchi:

Had to reinstall my windows 10 laptop, after the update, git clone, pull stopped working. So, trying to setting up the connection between my laptop and bitbucket, but keep failing with the below error.

Created a id_rsa file in my windows laptop.

```
ssh-keygen -t rsa -C "Daiki.NSWHP.BitBucket.v6" -f "Daiki.NSWHP.BitBucket.v6"
```

added this key

```
ssh-add Daiki.NSWHP.BitBucket.v6
```

created the config file under .ssh folder to reference the created id_rsa file

```
Host bitbucket.pathology.health.nsw.gov.au
User git
HostName bitbucket.pathology.health.nsw.gov.au
IdentityFile ~/.ssh/Daiki.NSWHP.BitBucket.v6
IdentitiesOnly yes
```

Paste the Daiki.NSWHP.BitBucket.v6.pub file content to the web bitbucket SSH key section. Then, run the below ssh command, this looks ok?

```
60049533@EHLCND1191JKK MINGW64 ~/.ssh
$ ssh -v git@bitbucket.pathology.health.nsw.gov.au
OpenSSH_9.2p1, OpenSSL 1.1.1t 7 Feb 2023
debug1: Reading configuration data /c/Users/60049533/.ssh/config
debug1: /c/Users/60049533/.ssh/config line 1: Applying options for bitbucket.pathology.health.nsw.gov.au
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to bitbucket.pathology.health.nsw.gov.au [3.106.154.208] port 7999.
debug1: Connection established.
debug1: identity file /c/Users/60049533/.ssh/Daiki.NSWHP.BitBucket.ed25519 type 3
debug1: identity file /c/Users/60049533/.ssh/Daiki.NSWHP.BitBucket.ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.2
debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.8.0
```

id_rsa.pub file content

```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDoBATVUmVUzQKhXAzGC4O7PmYRcEFVz+FOFBrEkVJghL2+Hl8j7Gv34M0tJiMnMgEh69/hG4ef5867fUtcDl3SjS4VK/GjM2BwrlHO7+yDMtva+HzYgnS97GZUSx6O/0g0nNGw6Ydd12/EgoKOG7Yx56uyTIfVzQM8GglTkbAPgGnNqr45D9VAj15L3loRyrTnW9EjtQL5Wx+nSBl08/B+MsZo8GHsAGSPFO0XvggePYl6/COLsNGeXadU4abtYEO+6PC4eRIZknn6gqmidwSs69ikKZMr2cEKxQ4ONpxSGLeZWyijj1AW49yFcQhyuLUQKDKG5XLZsHKxA9Jv/F9pZowAFM1i/SWQ4gBCur7aHxZfk4OA7YMeeJNsdr9Lyd70zhE9CDXWALZNS3GeuVuy5vxnMYT7IORZM+LEuIgRB3DZ1QdP0MB6Ez5OmO4WqpmInTiYM1rLKK0V+hNPQO7B+gDjqomkR+fRfKGP/oSQtLIf7Jf+GKTEFGms8ohgW/8= Daiki.NSWHP.BitBucket.v6
```

tried this command

```
plink.exe -i Daiki.NSWHP.BitBucket.v6.putty.ppk git@bitbucket.pathology.health.nsw.gov.au -P 7999 -l git -v
```

"Access is granted", but gitExtensions somehow not allowed me to pull or push

```
$ plink.exe -i Daiki.NSWHP.BitBucket.v6.putty.ppk git@bitbucket.pathology.health.nsw.gov.au -P 7999 -l git -v
Looking up host "bitbucket.pathology.health.nsw.gov.au" for SSH connection
Connecting to 3.106.154.208 port 7999
We claim version: SSH-2.0-PuTTY_Release_0.78
Connected to 3.106.154.208
Remote version: SSH-2.0-APACHE-SSHD-2.8.0
Using SSH protocol version 2
No GSSAPI security context available
Doing ECDH key exchange with curve Curve448, using hash SHA-512 (unaccelerated)
Host key fingerprint is:
ssh-rsa 2048 SHA256:kNCy3FYLRVq9dgVaQqu9tv9iZT0h6wX2mL6HzQGAVO4
Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
Initialised HMAC-SHA-256 (unaccelerated) outbound MAC algorithm
Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
Initialised HMAC-SHA-256 (unaccelerated) inbound MAC algorithm
Reading key file "Daiki.NSWHP.BitBucket.v6.putty.ppk"
Pageant is running. Requesting keys.
Pageant has 2 SSH-2 keys
Pageant key #0 matches configured key file
Using username "git".
Trying Pageant key #0
Authenticating with public key "Daiki.NSWHP.BitBucket.v6" from agent
Sending Pageant's response
Access granted
Opening main session channel
Opened main channel
Allocated pty
Server refused to start a shell/command
FATAL ERROR: Server refused to start a shell/command
```

this is the error from gitextensions.

```
"F:\mylibrary\Git\bin\git.exe" -c fetch.parallel=0 -c submodule.fetchJobs=0 pull --progress "origin"
FATAL ERROR: No supported authentication methods available (server sent: publickey)
fatal: Could not read from remote repository.
```

Now, I tried git clone command, this also failed with the below error.

```
60049533@EHLCND1191JKK MINGW64 ~/.ssh
$ git clone ssh://git@bitbucket.pathology.health.nsw.gov.au:7999/ps/plt-norm-auslab-std-v1.git
Cloning into 'plt-norm-auslab-std-v1'...
Server refused our key
FATAL ERROR: No supported authentication methods available (server sent: publickey)
fatal: Could not read from remote repository.
```

any idea what's causing this issue?

**UPDATE ON 31 MAR 2023**

When I remove the ssh:// from the git clone command like below, it started to work somehow. I don't know why it does not access the ssh command, but so far it works.

```
git clone git@bitbucket.pathology.health.nsw.gov.au:7999/ps/plt-norm-auslab-std-v1.git
```


Answers:
author: Daiki Haraguchi
body: removed the ssh from the git clone command. After this, git command started to work.

Before

git clone ssh://git@bitbucket

After

git clone git@bitbucket


author: Erez Maadani
body: Hey [@Daiki Haraguchi](/t5/user/viewprofilepage/user-id/5182318)

Couple of suggestions:

1. From the above, "Paste the id_rsa file content to the web bitbucket SSH key section." - Not sure if it's a typo or not, but you need to paste the ++**id_rsa.pub**++ file content to the web bitbucket SSH keys section ++under your account++.
2. When creating an ssh key, instead of "-t rsa", try using "-t ed255519"
3. According to the "plink.exe" output, your Pageant has 2 SSH keys. Make sure it's using the correct one or delete the un-needed key to make sure you are using the correct key.
4. Have a look at this link for more suggestions: <https://confluence.atlassian.com/bbkb/permission-denied-publickey-302811860.html>

comments: author: Daiki Haraguchi
body: Thanks for your reply, and I tried all of your suggestions, but still not working in gitextensions.


author: Erez Maadani
body: In your gitextensions settings, make sure you are using the same ssh client as above.


author: Daiki Haraguchi
body: Erez. I also tried with git clone without using gitextensioins, but still failing. Any idea?

```
$ git clone ssh://git@bitbucket.pathology.health.nsw.gov.au:7999/ps/plt-norm-auslab-std-v1.git
Cloning into 'plt-norm-auslab-std-v1'...
Server refused our key
FATAL ERROR: No supported authentication methods available (server sent: publickey)
fatal: Could not read from remote repository.
```


author: Daiki Haraguchi
body: When I remove the ssh:// from the git clone command like below, it started to work somehow. I don't know why it does not access the ssh command, but so far it works.

```
git clone git@bitbucket.pathology.health.nsw.gov.au:7999/ps/plt-norm-auslab-std-v1.git
```


Tags: atl-gruland

bitbucket-cloud

cloud