Skip to content

Commit

Permalink
add prepare home script to setup link for authorized keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bryopsida committed Jan 2, 2022
1 parent f651749 commit fe41b22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RUN usermod -s /bin/zsh developer
RUN adduser developer shadow

COPY ./Entrypoint.sh /usr/local/bin/entrypoint.sh
COPY ./PrepareHome.sh /usr/local/bin/prepare_home.sh
EXPOSE 3022/tcp
USER developer
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
4 changes: 4 additions & 0 deletions Entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ touch /etc/dropbear/authorized_keys
chmod 600 /etc/dropbear/authorized_keys
sudo chown -R developer:developer /home/developer

# setup home directory links/permissions etc
# this occurs on every container startup and is meant to be idempotent without overwriting existing files
/usr/local/bin/prepare_home.sh

exec dropbear -R -w -F -E -p 3022 -P /var/run/dropbear.pid
12 changes: 12 additions & 0 deletions PrepareHome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# ensure ~/.ssh exists
mkdir -p ~/.ssh

# create link to drop bear authorized keys
if [ -e ~/.ssh/authorized_keys ] ; then
echo "Authorized keys already exists, skipping..."
else
echo "Creating authorized_keys link..."
ln -s /etc/dropbear/authorized_keys ~/.ssh/authorized_keys
fi

0 comments on commit fe41b22

Please sign in to comment.