From f0ddcc00bc7d18f14464f1383be267493265eb2a Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 16 Aug 2024 12:23:53 -0500 Subject: [PATCH 1/5] Prime the devcontainer with github's ssh keys to avoid prompting during scripted operations --- .devcontainer/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cf4b37aca9..9a506a69b2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -92,3 +92,6 @@ RUN umask 0002 \ && mkdir -p /opt/conda/pkgs/cache/ && chown -R vscode:conda /opt/conda/pkgs/cache/ RUN mkdir -p /home/vscode/.conda/envs \ && ln -s /opt/conda/envs/mlos /home/vscode/.conda/envs/mlos + +# Try and prime the devcontainer's known ssh keys with the github one. +RUN SSH_AUTH_SOCK=/dev/null ssh -n -i /dev/null -o StrictHostKeyChecking=accept-new git@github.com From 753c51197d2af7fd63ebf58ffe1ef6c7ecc50a48 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 16 Aug 2024 12:37:04 -0500 Subject: [PATCH 2/5] tweak --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9a506a69b2..9ca1df4cd5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -94,4 +94,4 @@ RUN mkdir -p /home/vscode/.conda/envs \ && ln -s /opt/conda/envs/mlos /home/vscode/.conda/envs/mlos # Try and prime the devcontainer's known ssh keys with the github one. -RUN SSH_AUTH_SOCK=/dev/null ssh -n -i /dev/null -o StrictHostKeyChecking=accept-new git@github.com +RUN mkdir -p /home/vscode/.ssh && ssh-keyscan github.com | tee -a /home/vscode/.ssh/known_hosts From d868702ba9ff3c6b9685248e1be5e0e6711ee0cd Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 16 Aug 2024 12:43:39 -0500 Subject: [PATCH 3/5] tweaks --- .devcontainer/Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9ca1df4cd5..c9a2d0bbfb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -93,5 +93,9 @@ RUN umask 0002 \ RUN mkdir -p /home/vscode/.conda/envs \ && ln -s /opt/conda/envs/mlos /home/vscode/.conda/envs/mlos -# Try and prime the devcontainer's known ssh keys with the github one. -RUN mkdir -p /home/vscode/.ssh && ssh-keyscan github.com | tee -a /home/vscode/.ssh/known_hosts +# Try and prime the devcontainer's ssh known_hosts keys with the github one for scripted calls. +RUN mkdir -p /home/vscode/.ssh \ + && ( + grep -q ^github.com /home/vscode/.ssh/known_hosts \ + || ssh-keyscan github.com | tee -a /home/vscode/.ssh/known_hosts \ + ) From 69eb6014ce645e467d17cdf40ec630796e6e901d Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 16 Aug 2024 17:46:35 +0000 Subject: [PATCH 4/5] add a test for the change too --- .github/workflows/devcontainer.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index c07a902fc6..b57257a907 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -128,6 +128,10 @@ jobs: run: | docker exec --user vscode --env USER=vscode mlos-devcontainer printenv + - name: Check that github.com is in the ssh known_hosts file + run: | + docker exec --user vscode --env USER=vscode mlos-devcontainer grep ^github.com /home/vscode/.ssh/known_hosts + - name: Update the conda env in the devcontainer timeout-minutes: 10 run: | From 28de2b8251a33fd91b91fb82e7c60122745651dc Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 16 Aug 2024 18:00:08 +0000 Subject: [PATCH 5/5] fixup --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c9a2d0bbfb..8702d314cb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -95,7 +95,7 @@ RUN mkdir -p /home/vscode/.conda/envs \ # Try and prime the devcontainer's ssh known_hosts keys with the github one for scripted calls. RUN mkdir -p /home/vscode/.ssh \ - && ( + && ( \ grep -q ^github.com /home/vscode/.ssh/known_hosts \ || ssh-keyscan github.com | tee -a /home/vscode/.ssh/known_hosts \ )