Coder.comC
Coder.comโ€ข10mo agoโ€ข
7 replies
David

envbuilder clone a private git repository?

- I've added my Coder SSH public key to github.
- I'm using a template based on the aws-devcontainer template.
- I set repo_url to git@github.com:foo/bar

Envbuilder fails to authenticate:
envbuilder v1.1.0+a3a6a83 - Build development environments from repositories in a container
#1: ๐Ÿ“ฆ Cloning git@github.com:foo/bar to /workspaces/bar...
#1: ๐Ÿ”‘ Using SSH authentication!
#1: ๐Ÿ”‘ No SSH key found, falling back to agent!
#1: โŒ Failed to connect to SSH agent: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
#1: Parsed Git URL as "ssh://git@github.com/foo/bar"
Failed to clone repository: clone "git@github.com:foo/bar": error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
Falling back to the default image...


After the fall back image starts, I can git clone and the agent ssh successfully authenticates.

I'm guessing envbuilder is trying to clone the repo before the agent is pulled by the ENVBUILDER_INIT_SCRIPT. I think the logs corroborate that.

Is there a way to get the clone to work the first startup?
Solution
Just to follow up on this for anyone else searching here for a solution, you can set the following in your Terraform locals:
envbuilder_env = {
    "ENVBUILDER_GIT_SSH_PRIVATE_KEY_BASE64": base64encode(data.coder_workspace_owner.me.ssh_private_key),
Was this page helpful?