How to inject ssh key into build image run with CircleCI local executor

My builds are working fine on CircleCI’s cloud executor; my error was with something else.

I cannot get ssh cloning of private repositories to work using the local CircleCI executor. I have tried injecting my SSH key by passing an environment variable with its value and saving its values to a file and then running ssh-agent, and ssh-add with expect. However, expect doesn’t seem to work in docker; ssh-add still tries to prompt for the password.

I am using CircleCI 2.0 with a custom docker image. I want to use the ssh key to clone dependent repositories; I am coping the package that I want to test from my local directory rather than cloning it from GitHub.

Any advice would be appreciated about how to inject an ssh key into a build image run with the local executor.

2 Likes