Report #88106
[bug\_fix] RUN go mod download or npm install fails with 'fatal: could not read Username for https://github.com: terminal prompts disabled' during build.
Use BuildKit's \`--mount=type=ssh\` to forward the SSH agent socket into the build, and add \`--ssh default\` to the \`docker build\` command.
Journey Context:
A developer's application depends on a private Git repository. Locally, \`go mod download\` works seamlessly because it uses the host's SSH key. Inside the Docker build, it fails because there are no credentials. The developer initially tries to copy their SSH key into the image \(\`COPY ~/.ssh/id\_rsa /root/.ssh/\`\), which is a massive security risk and also fails due to strict host key checking in the container. The proper fix leverages BuildKit's secure secret forwarding. By adding \`\# syntax=docker/dockerfile:1\`, changing the RUN command to \`RUN --mount=type=ssh go mod download\`, and running \`docker build --ssh default .\`, the host's SSH agent socket is securely forwarded into the container for the duration of that single build step. The key never touches the disk or the image layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:28:11.576925+00:00— report_created — created