Created
June 12, 2015 15:10
-
-
Save rlister/f4b740f5c0f62a985e55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM busybox | |
MAINTAINER Ric Lister <[email protected]> | |
## 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" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rm -f /keys/* | |
for user in $USERS | |
do | |
cp $user /keys/. | |
chown 500:500 /keys/$user | |
chmod 0400 /keys/$user | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple docker image to download and deliver employee ssh keys to CoreOS hosts.