From 4bddbabf9714cb71ea610447586381aa26b9e071 Mon Sep 17 00:00:00 2001 From: Olivier reivilibre Date: Thu, 4 Jun 2026 16:10:03 +0100 Subject: [PATCH] Use `~` in IdentityFile statement to allow portability --- README.md | 3 +-- index.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3028201..449f1d5 100644 --- a/README.md +++ b/README.md @@ -157,9 +157,8 @@ Workflow: Dockerfile: ```Dockerfile -# Copy the two files in place and fix different path/locations inside the Docker image +# Copy the two files in place COPY root-config /root/ -RUN sed 's|/home/runner|/root|g' -i.bak /root/.ssh/config ``` Keep in mind that the resulting Docker image now might contain these customized Git and SSH configuration files! Your private SSH keys are never written to files anywhere, just loaded into the SSH agent and forwarded into the container. The config files might, however, give away details about your build or development process and contain the names and URLs of your (private) repositories. You might want to use a multi-staged build to make sure these files do not end up in the final image. diff --git a/index.js b/index.js index d28a764..2ad9e45 100644 --- a/index.js +++ b/index.js @@ -66,7 +66,9 @@ try { const sshConfig = `\nHost key-${sha256}.github.com\n` + ` HostName github.com\n` - + ` IdentityFile ${homeSsh}/key-${sha256}\n` + // ssh expands `~` to $HOME. + // This lets the config be copied into a container and used without modification. + + ` IdentityFile ~/.ssh/key-${sha256}\n` + ` IdentitiesOnly yes\n`; fs.appendFileSync(`${homeSsh}/config`, sshConfig);