Skip to content

Commit

Permalink
Add ssh renewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ckwalsh committed Dec 28, 2020
1 parent 9460e58 commit bfc7763
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions renewer/ssh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM smallstep/step-cli:0.15.3

USER root
ENV USER_KEY="/var/run/autocert.step.sm/ssh_user_key"
ENV HOST_KEY="/var/run/autocert.step.sm/ssh_host_key"
ENV STEP_ROOT="/var/run/autocert.step.sm/root.crt"
ENV RENEWAL_SEC="21600"
ENV RENEWAL_JITTER_SEC="600"

COPY renewer/ssh/renewer.sh /home/step/
RUN chmod +x /home/step/renewer.sh
CMD ["/home/step/renewer.sh"]
15 changes: 15 additions & 0 deletions renewer/ssh/renewer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

if [ "$STEP_HOST" == "" ];
then
KEY=$USER_KEY
else
KEY=$HOST_KEY
fi

while true; do
sleep $(expr $RENEWAL_SEC + $RANDOM % $RENEWAL_JITTER_SEC);
step ssh renew -f $KEY-cert.pub $KEY;
done;

0 comments on commit bfc7763

Please sign in to comment.