Forums

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

Why using multiple SSH keys in Step/scripts that uses environment variable don't always use default?

Michael Brizic September 3, 2019

I followed the section titled "Use multiple SSH keys in your pipeline" on this page: https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html
However, I notice it only sometimes works. 

The image I use is: atlassian/default-image:2 and I follow exactly the steps outlined in the Wiki setting up the known_hosts, echoing the secured environment variable SSH key into the default ~/.ssh/id_rsa file

If I enabled `ssh -vv` for my ssh command and allow the default of ~/.ssh/id_rsa to be picked up I observe that this only works sometimes. In some cases, depending on the bitbucket repository and pipeline where it is used, it tries to use a different default id_rsa, for example from: 

debug2: we did not send a packet, disable method

debug1: Next authentication method: publickey

debug1: Trying private key: /opt/atlassian/pipelines/agent/ssh/id_rsa

debug2: we sent a publickey packet, wait for reply

However, in a different run of exactly the same script in a different repo and pipeline (same base Docker image too), it returns this:

debug2: we did not send a packet, disable method

debug1: Next authentication method: publickey

debug1: Trying private key: /root/.ssh/id_rsa

debug2: we sent a publickey packet, wait for replydebug1: Authentication succeeded (publickey).

I am not passing `-i` to the `ssh` command since documentation states the default id_rsa file will be used, but now I feel that `-i` is required to ensure the correct id_rsa file is used.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events