mserranom / bbrun

Run Bitbucket Pipelines locally
MIT License
203 stars 32 forks source link

SSH Keys #46

Open puppeteer701vungle opened 5 years ago

puppeteer701vungle commented 5 years ago

It would be beneficial to add a flag for ssh keys, because a pipeline could be installing a private package.

Brewal commented 4 years ago

Is there any plan / workaroud for this ?

bestit-ewieser commented 4 years ago

I added the following volume to line 53 of the docker.js file: -v ~/.ssh:/root/.ssh:ro

: `run --rm -P -v ${pwd()}:${workDir} -v ~/.ssh:/root/.ssh:ro -w ${workDir} ${image} bash ${BUILD_SCRIPT}`;

Thus your local SSH-keys are mapped into the docker container.

holylander commented 3 years ago

do you know if such config would work on a windows machine? thanks

bestit-ewieser commented 3 years ago

do you know if such config would work on a windows machine? thanks

Unfortunately I have no experience on windows machines. It might just be necessary to swap the placeholder for the user-folder (https://stackoverflow.com/questions/20226147/where-does-github-for-windows-keep-its-ssh-key)?

holylander commented 3 years ago

@bestit-ewieser thanks mate! :) If windows filesystem, all you need to is -v C:\\Users\\[username]\\.ssh:/root/.ssh:ro However, I got another error after trying to use the ssh keys:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/root/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

Therefore, I ended in creating a docker image, based on the following docker file, within a folder, with my windows generated ssh key:

FROM node:10.15.3
RUN mkdir /root/.ssh/
COPY ./id_rsa.pub /root/.ssh/id_rsa.pub
COPY ./id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa

docker build . -t node:10.15.3-custom And then, update the bitbucket pipeline so it uses my new docker image image: node:10.15.3:custom