Skip to content

Commit 2215b86

Browse files
committed
fix: Auto generate SSH key if it doesn't exist
1 parent 8597933 commit 2215b86

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.devcontainer/Dockerfile

+13-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
77
python3-pip \
88
git \
99
curl \
10-
fish \
10+
fish \
1111
&& apt-get clean \
1212
&& rm -rf /var/lib/apt/lists/*
1313

1414
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
1515
&& chown -R vscode:vscode /home/vscode/.local/share/CMakeTools
1616

17+
RUN mkdir -p /home/vscode/.ssh \
18+
&& chown vscode:vscode /home/vscode/.ssh \
19+
&& chmod 700 /home/vscode/.ssh
20+
1721
# Install arduino-cli
1822
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
1923

@@ -26,7 +30,7 @@ ENV PATH="/usr/local/bin:${PATH}"
2630
# Create workspace directory
2731
WORKDIR /workspace
2832

29-
# Copy arduino-cli configuration (customize to your actual path)
33+
# Copy arduino-cli configuration (customise to your actual path)
3034
COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
3135

3236
# Install build essentials
@@ -64,7 +68,10 @@ RUN mkdir -p /home/vscode/.config/fish && \
6468
echo 'set -gx PATH /usr/local/bin $PATH' >> /home/vscode/.config/fish/config.fish && \
6569
echo '# Welcome to the Fish shell inside the dev container!' >> /home/vscode/.config/fish/config.fish
6670

67-
# If you want to default to fish shell (uncomment below),
68-
# you can either set the SHELL environment variable or change the user default shell:
69-
# RUN chsh -s /usr/bin/fish vscode
70-
# ENV SHELL=/usr/bin/fish
71+
# Generate SSH keys and set proper ownership and permissions
72+
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
73+
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
74+
chmod 600 /home/vscode/.ssh/id_rsa && \
75+
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
76+
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
77+
fi

0 commit comments

Comments
 (0)