Why does my pipeline can't connect to a remote host via SSH?

Rodrigo Baptista August 5, 2020

Hey guys, 
since two days im now searching for any solution for my issue.
I'm trying to connect from the CD pipeline to the remote host via ssh to deploy a new package but the connection does not work properly. 
I created a public/private key pair, without passphrase, and pasted the public key to the authorized_keys on the remote host. I also checked connecting from my local PC to the host via the same keys and it worked.  Could someone help me to get it working or give me some hints to find the problem?

Thanks a lot an advance.

My Pipeline.yml:

image: atlassian/default-image:2
pipelines:
default:
- step:
script:
- ssh -v rbaptista@xxx.xxx.xxx.xxx
- echo "It works!"

Here is the error output from my pipeline:

The "xxx.xxx.xxx.xxx" is just my edited IP address. 

 

Bildschirmfoto 2020-08-05 um 14.36.51.png

As you can see it tells me "Authenticated with partial success.". Does anyone of you knows this error?

best regards,

Rodrigo

 

1 answer

1 accepted

0 votes
Answer accepted
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 5, 2020

Hi @Rodrigo Baptista ,

it's a good case to use ssh-run pipe, where all stuff related to ssh connection from the Bitbucket Pipelines simplified for you.

script:
  - pipe: atlassian/ssh-run:0.2.6
    variables:
      SSH_USER: 'rbaptista'
      SERVER: 'xxx.xxx.xxx.xxx'
      COMMAND: 'echo $HOSTNAME'

More advanced examples you can find in the ssh-run pipe's Readme.

Note! If you want to use the default behaviour for using the configured SSH key and known hosts file, you must have configured the SSH private key and known_hosts to be used for the This pipe in your Pipelines settings (see docs).

It'd be nice if you provide us with feedback about your case!

Rodrigo Baptista August 5, 2020

Hi @Oleksandr Kyrdan,

thanks for your help.
The method you showed helped me out.

best regards, 


Rodrigo 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events