Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

deploy the code to ec2 machine using jump server via anisble getting Connection closed by UNKNOWN

Muhammad Ahtisham Ul Haq February 9, 2023

I try to use ansible in bitbucket pipeline to deploy to ec2 using a jump server. but whenever i try to run the pipeline i get the error
Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host\r\nConnection closed by UNKNOWN port 65535"
the ansible code is working fine to my local machine when i manual try to update the code.
I have also try to remove the host key checking in the ansible host or inventory file but no luck on bitbucket pipeline.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2023

Hi @Muhammad Ahtisham Ul Haq,

I would like to ask some questions to better understand your setup:

1) Are you using Pipelines builds that run in our own infrastructure or are you using Runners?

2) If you're using runners, which type of runner are you using (Linux Docker, Linux Shell, Windows, or MacOS)? What is the version of the runner?

3) In order to connect to your server via SSH, are you using the SSH key pair generated in the Bitbucket UI from Repository settings or an SSH key pair you generated yourself?

4) Can you add the argument -vvv to the SSH command in order to get more verbose output, and paste the output here?

Kind regards,
Theodora

Muhammad Ahtisham Ul Haq February 13, 2023

I am using atlassian/default-image:4 in pipeline.

i generated the public and private ke from the pipeline ssh-key from bitbucket UI setting and add the public key to the server.

When i try ansible on my machine using that key i am able to configure the server but in bitbucket pipeline i get the error "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host\r\nConnection closed by UNKNOWN port 65535".

Will try to use -vvv in the host of the ansible and share

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2023

Hi,

Are you using Pipelines builds that run in our own infrastructure or are you using one of our Runners listed on this page? I see that your workspace doesn't have any Pipelines build minutes usage for the current billing period. If you're using a runner, then the bitbucket-pipelines.yml file will have the runs-on parameter for the steps that run on a runner.

Please let me know, and it would also be useful to have the output of the ssh command with the -vvv argument.

Kind regards,
Theodora

Suggest an answer

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

Atlassian Community Events