Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

SSH Permission denied (publickey).

TechXLNS DevUser October 29, 2024

While ssh to server getting the error, 
it is successfully connecting with same IP from the local 

2 answers

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2024

Hi and welcome to the community!

We need some additional details to better help you:

  1. You mentioned that you are using a self-hosted runner. Is it a Linux Docker, Linux Shell, Windows, or MacOS runner?

  2. How did you set up SSH access between Pipelines and your server? Did you generate an SSH key pair from Repository settings > section Pipelines - SSH keys? Or did you store the base-64 encoded value of the private SSH key in a variable?

  3. If you used a variable, what command are you using in your bitbucket-pipelines.yml file's script to create the private key?

  4. Are you using an SSH command to connect to your server or are you perhaps using one of our pipes, e.g. one of these https://bitbucket.org/product/features/pipelines/integrations?&search=ssh ?

  5. Can you provide the command from your yml file that fails with this error? Please make sure you sanitize any private/sensitive data in the command, before sharing.

Kind regards,
Theodora

TechXLNS DevUser November 3, 2024

Hi Theodora, 
please find the additional details

1. The self-hosted runner is Linux Docker

2. I have generated the in our server ( which is our deployment server)

3. we did not mention any private key as we have updated the ssh key in our repository.

4. command in the pipeline used 
"

- ssh -o BatchMode=yes -o StrictHostKeyChecking=no deploy@<public ip> 'echo "helloworld "
5. Error as "Permission denied (publickey)."
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 4, 2024

Hi,

Thank you for the info.

You said:

we did not mention any private key as we have updated the ssh key in our repository.

Can you please confirm if you have added the private and public SSH key you generated in the Repository settings of the repo > section Pipelines - SSH keys?

If so, when you run a Pipelines build with a Linux Docker runner the private SSH key will be located at

/tmp/runner-uuid/ssh/id_rsa

in the build container, where runner-uuid is the UUID of the runner. You can find the runner UUID in the preconfigured command you used to start the runner. In this command, you will see a variable like the following:

-e RUNNER_UUID={b609961f-891e-c872-c36b-f3f2c315d186}

This means that the SSH key is located at

/tmp/b609961f-891e-c872-c36b-f3f2c315d186/ssh/id_rsa

You can then adjust the SSH command in your bitbucket-pipelines.yml file and add the -i option, which allows you to specify which SSH key you want the command to use:

- ssh -i /tmp/runner-uuid/ssh/id_rsa -o BatchMode=yes -o StrictHostKeyChecking=no deploy@<public ip> 'echo "helloworld "

Replace runner-uuid in the command with the UUID of your runner.


Please also ensure that the public SSH key is added to the ~/.ssh/authorized_keys of the server you want to connect to.

Please feel free to let me know how it goes and if you have any questions.

Kind regards,
Theodora

TechXLNS DevUser November 11, 2024

Hi Theodora,

Thanks it working for me

Like Theodora Boudale likes this
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 11, 2024

That's good to hear, thank you for the update!

Please feel free to reach out if you ever need anything else!

0 votes
TechXLNS DevUser October 29, 2024

Here i am accessing the server in the bit bucket pipeline and that runner is self hosted 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events