1
0
mirror of https://github.com/rancher/os.git synced 2025-09-25 04:37:02 +00:00

Rewrite update-ssh-keys in Go

This commit is contained in:
Josh Curl
2016-11-16 13:02:35 -08:00
parent 2b0638c95f
commit bba93792d5
4 changed files with 105 additions and 32 deletions

View File

@@ -1,5 +1,4 @@
FROM rancher/os-base
COPY update-ssh-keys /usr/sbin/
COPY build/lsb-release /etc/
RUN sed -i 's/rancher:!/rancher:*/g' /etc/shadow && \
sed -i 's/docker:!/docker:*/g' /etc/shadow && \

View File

@@ -1,20 +0,0 @@
#!/bin/bash
USERNAME=$1
HOME_DIR=$(grep ^$USERNAME /etc/passwd | cut -f6 -d:)
if [ ! -d $HOME_DIR/.ssh ]; then
mkdir -p $HOME_DIR/.ssh
chmod 0700 $HOME_DIR/.ssh
fi
if [ ! -e $HOME_DIR/.ssh/authorized_keys ]; then
touch $HOME_DIR/.ssh/authorized_keys
chmod 0600 $HOME_DIR/.ssh/authorized_keys
fi
if ! grep -q "$2" $HOME_DIR/.ssh/authorized_keys; then
echo "$2" >> $HOME_DIR/.ssh/authorized_keys
fi
chown -R $USERNAME $HOME_DIR/.ssh