From bbb3dd243a6831b742a0f40d942e45644b8c65d1 Mon Sep 17 00:00:00 2001 From: Ola Skavhaug Date: Fri, 19 Jun 2020 12:25:07 +0200 Subject: [PATCH] Add multi cert access to dev.xal.no users --- enable_ssh.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/enable_ssh.sh b/enable_ssh.sh index 479f1ac..537ac1c 100644 --- a/enable_ssh.sh +++ b/enable_ssh.sh @@ -1,3 +1,17 @@ #! /bin/bash -cp /xal/internal/pub_keys/$1/* /home/$1/.ssh/authorized_keys +base_path=/xal/internal + +num_files=$(ls -1 ${base_path}/pub_keys/$1/ | wc -l) +if (( num_files > 1)); then + rm -f ${base_path}/pub_keys/$1/generated_authorized_keys + keys=$(find ${base_path}/pub_keys/$1 | egrep '\.pub\>') + for key in $keys + do + cat $key >> ${base_path}/pub_keys/$1/generated_authorized_keys + done + mv /xal/internal/pub_keys/$1/generated_authorized_keys /home/$1/.ssh/authorized_keys +else + cp /xal/internal/pub_keys/$1/* /home/$1/.ssh/authorized_keys +fi + chown $1 /home/$1/.ssh/*