Skip to content

Commit

Permalink
Merge pull request #105 from crosscite/reconfigure-ssh
Browse files Browse the repository at this point in the history
Reconfigure ssh
  • Loading branch information
digitaldogsbody authored Jan 18, 2022
2 parents 5d7d7de + b12999f commit fe31045
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" &&
apt-get install ntp wget tzdata -y && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Remove unused SSH keys
RUN rm -f /etc/service/sshd/down && \
/etc/my_init.d/00_regen_ssh_host_keys.sh

# Enable Passenger and Nginx and remove the default site
# Preserve env variables for nginx
RUN rm -f /etc/service/nginx/down && \
Expand Down Expand Up @@ -51,9 +47,16 @@ RUN mkdir -p tmp/pids && \
chown -R app:app /home/app/webapp && \
chmod -R 755 /home/app/webapp


# enable SSH
RUN rm -f /etc/service/sshd/down && \
/etc/my_init.d/00_regen_ssh_host_keys.sh

# Run additional scripts during container startup (i.e. not at build time)
RUN mkdir -p /etc/my_init.d
COPY vendor/docker/10_enable_ssh.sh /etc/my_init.d/10_enable_ssh.sh

# install custom ssh key during startup
COPY vendor/docker/10_ssh.sh /etc/my_init.d/10_ssh.sh

# Expose web
EXPOSE 80
9 changes: 3 additions & 6 deletions vendor/docker/10_enable_ssh.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/sh
if [ "${SSH_PUBLIC_KEY}" ]; then
rm -f /etc/service/sshd/down
dockerize -template /home/app/webapp/vendor/docker/authorized_keys.tmpl:/home/app/.ssh/authorized_keys
chown app:app /home/app/.ssh/authorized_keys
chmod 600 /home/app/.ssh/authorized_keys
fi
if [ "${PUBLIC_KEY}" ]; then
echo "${PUBLIC_KEY}" > /root/.ssh/authorized_keys
fi

0 comments on commit fe31045

Please sign in to comment.