From 7d6d086ff31ca41228f637e2c52db5ae2e587f2a Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Sun, 26 Feb 2023 11:46:54 -0600 Subject: [PATCH] ensure paths exists before writing keys Ensure the target path exists before writing the keys so there's no errors for the user. Dropped a temp variable as well. --- 99-ssh-keys.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/99-ssh-keys.sh b/99-ssh-keys.sh index ec7bb01..8aae1d8 100755 --- a/99-ssh-keys.sh +++ b/99-ssh-keys.sh @@ -28,9 +28,9 @@ if [ ! -f "$user_authorized_keys_file" ]; then fi # Reads the user file line by line and adds the key to the authorized_keys file -file=$user_authorized_keys_file +mkdir -p "$(dirname ${udm_authorized_keys_file})" while IFS= read -r line || [ -n "$line" ]; do echo $line >>$udm_authorized_keys_file -done <"$file" +done <"$user_authorized_keys_file" exit 0