Skip to content

Instantly share code, notes, and snippets.

@rlister
Created June 12, 2015 15:10
Show Gist options
  • Save rlister/f4b740f5c0f62a985e55 to your computer and use it in GitHub Desktop.
Save rlister/f4b740f5c0f62a985e55 to your computer and use it in GitHub Desktop.
FROM busybox
MAINTAINER Ric Lister <rlister@gmail.com>
## busybox wget cannot do https, so grab curl binary
ENV CURL_VERSION 7.30.0
RUN (wget -O - http://www.magicermine.com/demos/curl/curl/curl-${CURL_VERSION}.ermine.tar.bz2 | bunzip2 -c - | tar xf -) \
&& mv /curl-${CURL_VERSION}.ermine/curl.ermine /bin/curl \
&& rm -rf /curl-${CURL_VERSION}.ermine
WORKDIR /app
## edit this to add/remove users by their github username
ENV USERS alice bob cathy dan
## download public keys from github, add newline to each file for update-ssh-keys on CoreOS
RUN for user in $USERS; do curl -k https://github.com/${user}.keys -o ${user}; echo >> ${user}; done
ADD ./run.sh /app/run.sh
## write keys to mounted volume
CMD [ "./run.sh" ]
#!/bin/sh
rm -f /keys/*
for user in $USERS
do
cp $user /keys/.
chown 500:500 /keys/$user
chmod 0400 /keys/$user
done
[Unit]
Description=SSH key delivery
Requires=docker.service
[Service]
Type=oneshot
User=core
ExecStartPre=-/usr/bin/docker rm ssh_keys
ExecStartPre=/usr/bin/docker pull index.mydomain.com/ssh_keys:master
ExecStart=/bin/bash -c 'docker run --name ssh_keys -v /home/core/.ssh/authorized_keys.d:/keys index.mydomain.com/ssh_keys:master && update-ssh-keys -l'
[X-Fleet]
Global=true
[Unit]
Description=SSH key update
Requires=docker.service
Requires=ssh_keys.service
[Timer]
OnBootSec=1min
OnUnitActiveSec=1h
Unit=ssh_keys.service
[X-Fleet]
Global=true
@rlister
Copy link
Author

rlister commented Jun 12, 2015

Simple docker image to download and deliver employee ssh keys to CoreOS hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment