Machine Users in bitbucket to sync multiple repositories


I am trying to checkout my project repository then clone another repository in to the same job. This is because we have created a framework that compiles html via gulp/handlebars using project related assets and content in json files which are contained in a separate repo.

Here is the relevant part of the config.yml file.

version: 2
      - image: circleci/node:8.12.0-browsers-legacy
      - checkout
      - add_ssh_keys:
            - "b1:79:b2:de:ce:1d:59:f0:83:6b:a4:b1:03:8c:7d:e6"
            - "ec:66:74:bb:b3:25:fa:82:57:58:58:94:01:eb:1b:b2"
      - run: 
          name: clone second repo
          command: sudo git clone<OUR-COMPANY-NAME/OUR-REPO.git /home/circleci/project/OUR-REPO
          no_output_timeout: 1200

I gather I need to make a machine user. The problem is that we are using Bitbucket and all of the machine user related instructions seem to be for Github. Does anyone know how I can access two separate Bitbucket repositiories in the same job? I have so far had no luck creating a machine user in Bitbucket. I have added various SSH keys created by getting the details from Inspect as mentioned in another ticket. None have worked. I have also created a new user in Bitbucket and tried adding SSH details to that but am unable to add projects to that for some reason.

The error I get back from this gives me a fingerprint for an SSH key I haven’t defined and as far as I can gather is the default known host RSA for Bitbucket on my local machine. So the add__ssh_keys instruction is not being respected.

Any help would be massively appreciated. Thanks!


You could just take a look at a successful checkout step, in the build UI, to see how it does the key stuff. It doesn’t need the add_ssh_keys (for the primary repo) since it copies the private key to ~/.ssh/id_rsa itself. Could you do the same, and get rid of add_ssh_keys?

The other thing you could do is to examine the output of add_ssh_keys to see where it is going wrong. For example, there are some kinds of key encryption that are not supported. Would you paste that here, in a formatted block? I think the console output of that is not sensitive, but you can always munge it a bit if you are not sure.

Okay so found the solution here: Git clone fails in Circle 2.0
mayu’s answer at the end worked for me. It’s to do with adding StrictHostKeyCheckingmanually before running the git clone.

Machine user not necessary. halfer’s advice above pointed me in the right direction so thank you halfer!

1 Like

No worries, let me pass on that thanks to @mayu also :smiley_cat:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.