Skip to content

Commit

Permalink
sey ssh pub key from environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
broizter committed Mar 4, 2024
1 parent 61b388a commit 68486b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ rm /etc/motd && \
rm /etc/update-motd.d/10-uname && \
mkdir /var/run/sshd && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config && \
sed -i 's/X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
sed -i 's/X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config && \
if ! [ -d /root/.ssh ]; then mkdir /root/.ssh ; fi && \
if ! [ -f /root/.ssh/authorized_keys ] ; then touch /root/.ssh/authorized_keys ; fi && \
chmod 700 /root/.ssh && \
chmod 400 /root/.ssh/authorized_keys

COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/

EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]
CMD ["/bin/bash", "-c", "echo $SSH_PUBLIC_KEY > /root/.ssh/authorized_keys; /usr/sbin/sshd -D"]

0 comments on commit 68486b1

Please sign in to comment.