SCP Task fail : Exhausted available authentication methods
Asked by Carlo:

Bamboo version 8.2.5 build 80211

I cannot not get SCP Task to work, not even once.

on the remote host "someserver55" I generated:

ssh-keygen -t rsa

with a passphrase. (I have also generated another key with no passphrase, same issue).

I upload the private key : choose "Authentication Type: SSH private key"

I include "SSH Passphrase" on the field.

I have tried other remote hosts and same issue eveytime!

"Exhausted available authentication methods.."

Example:

28-Sep-2022 11:11:50 Connecting to someserver55 on port: 22  
28-Sep-2022 11:11:50 Failed to connect to host  
28-Sep-2022 11:11:50 net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods  
28-Sep-2022 11:11:50 at net.schmizz.sshj.SSHClient.auth(SSHClient.java:227)  
28-Sep-2022 11:11:50 at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:342)  
28-Sep-2022 11:11:50 at com.atlassian.bamboo.plugins.scp.ScpTask.execute(ScpTask.java:176)

Please advise.

Thanks!


Answers:
author: Carlo
body: Hey Eduardo,

I recreated the PEM key:

ssh-keygen -t rsa -m PEM

Confirmed its in PEM format:

foo: PEM RSA private key

Same issue :(

I followed: <https://confluence.atlassian.com/bamboo0802/using-the-scp-task-in-bamboo-1103433190.html?permissionViolation=true>

but this article does not mention the key format requirements (PEM, etc).

After generating the private key on the target server "ssh-keygen -t rsa -m PEM" it created a file that I called "foo". I uploaded this key to bamboo SCP Task, but first I had to change the read permissions to 644 (chmod 644 foo). Else it cant be read by Bamboo. (is this correct?)

Am I suppose to do something after generating the private key besides uploading this "foo" file to bamboo? (no passphrase).

Thanks!

comments: author: Eduardo Alvarenga
body: Hello [@Carlo](/t5/user/viewprofilepage/user-id/5041964),

When you create an OpenSSH key pair, two files are generated, one is the private key (**foo** ) and the other is the public key (**foo.pub**).

Your client (Bamboo) should use the **PRIVATE KEY (foo)** , whilst your target server should have the equivalent **PUBLIC KEY (foo.pub)** added to its authorization file.

You need to add the contents of **foo.pub** to your target host's **\<username\>/.ssh/authorized_keys** file.

Cheers,

Eduardo Alvarenga  
Atlassian Support APAC


author: Carlo
body: I have just done this just now, with and without a passphrase, exact same issue.

I feel like this should not be this difficult and pretty straight forward. I'm not sure what I am missing.

I confirmed that the authorized_keys file does have the foo.pub entry.

Do the permissions on any of the files under "/root/.ssh" matter? (the default perms ok?)

Does it matter that my target host is a Linux box (**myLinuxServer** ) and the bamboo agent is on a Windows server? ("On agent: **someWindowsServer.com**" below):

---------------------

started building on agent **someWindowsServer.com** (2), bamboo version: 8.2.5

...

Release: release-1 master

TriggerManual run by Carlo

Completed 03 Oct 2022 10:24 AM

Duration\< 1 second

On agent: **someWindowsServer.com**

Status: FAILED

Webhooks: No webhooks have been recorded

----------------------

03-Oct-2022 10:24:30 Connecting to **myLinuxServer** on port: 22  
03-Oct-2022 10:24:31 Failed to connect to host  
03-Oct-2022 10:24:31 net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods

Thanks.


author: Eduardo Alvarenga
body: Hello [@Carlo](/t5/user/viewprofilepage/user-id/5041964)

Check your target SSH host logs and validate if any message can give you a clue.

I noticed you are using root as the account, OpenSSH does not Allow Root login by default. And you will have to explicitly allow it by setting:

```
PermitRootLogin yes
```

On */etc/ssh/sshd_config*

Regards,  
Eduardo Alvarenga  
Atlassian Support APAC


author: Carlo
body: Good suggestion!

Confirmed: PermitRootLogin yes

I ran the deployment and then got the logs

Logs:

Oct 04 16:31:17 myLinuxServer sshd\[25984\]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key

<br />

Oct 04 16:31:17 myLinuxServer sshd\[25984\]: Connection from \[someIP\] port 22568 on \[someIP\] port 22

<br />

Oct 04 16:31:17 myLinuxServer sshd\[25984\]: Failed publickey for root from \[someIP\] port 22568 ssh2: RSA SHA256:\[random 44 char string here\]

"Could not load host key: /etc/ssh/ssh_host_dsa_key" hmmm

Still checking into this...


author: Carlo
body: I regenerated:

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

This created two files:

ssh_host_dsa_key (PEM format confirmed)

ssh_host_dsa_key.pub: OpenSSH DSA public key

Reuploaded the priv key to Bamboo (no passphrase)

Appended the ".pub" into /root/.ssh/authorized_keys

Output:

Oct 06 11:09:26 myLinuxServer sshd\[2703\]: Failed publickey for root from \[someIPaddr\] port 22929 ssh2: DSA SHA256:\[some random chars\]

:(


author: Eduardo Alvarenga
body: Hello [@Carlo](/t5/user/viewprofilepage/user-id/5041964)

Welcome to **Atlassian Community**!

If appears the SSH server is rejecting any authentication tentatives. Are you able to connect to the SSH host by using ssh along with the private key on the command line?

Bamboo expects the Private key to be in PEM format. Did you convert/exported the private key to PEM before importing it on Bamboo? If not please run the following and re-import the private key:

```
ssh-keygen -p -f /location/of/private_key_file -e -m pem > private_key.pem
```

<br />

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Carlo
body: Im new to this forum. I replied above. (woops) :)


Tags: scp