From 02b5d4d09e2f3137ee264274fe948bd5c3c5daac Mon Sep 17 00:00:00 2001 From: Adrian Dvergsdal Date: Mon, 21 Dec 2015 00:55:32 +0100 Subject: [PATCH] Check if folder is missing --- entrypoint | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/entrypoint b/entrypoint index cad7f92..62a636c 100755 --- a/entrypoint +++ b/entrypoint @@ -55,6 +55,7 @@ function createUser() { fi useradd $useraddOptions $user + mkdir -p /home/$user chown root:root /home/$user chmod 755 /home/$user @@ -65,9 +66,12 @@ function createUser() { echo "$user:$pass" | chpasswd $chpasswdOptions - cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys - chown $user /home/$user/.ssh/authorized_keys - chmod 600 /home/$user/.ssh/authorized_keys + # Add SSH keys to authorized_keys with valid permissions + if [ -d /home/$user/.ssh/keys ]; then + cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys + chown $user /home/$user/.ssh/authorized_keys + chmod 600 /home/$user/.ssh/authorized_keys + fi } if [[ $1 =~ ^--help$|^-h$ ]]; then