20482: Improves file/dir creation on user_data script.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 11 May 2023 14:52:36 +0000 (11:52 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Thu, 11 May 2023 14:52:36 +0000 (11:52 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

tools/salt-install/terraform/aws/services/user_data.sh

index 68af17ee2fe8d78c8ae47765c300dfb9b2f43938..ada3e84ad9046964ff134f29122e8c8fe168ee79 100644 (file)
@@ -20,10 +20,6 @@ apt-get -o Acquire::ForceIPv4=true install -y git curl
 
 SSH_DIR="/home/${deploy_user}/.ssh"
 if [ ! -d "$${SSH_DIR}" ]; then
-  mkdir $${SSH_DIR}
-  chown ${deploy_user}.${deploy_user} $${SSH_DIR}
-  chmod 700 $${SSH_DIR}
+  install -d -o ${deploy_user} -g ${deploy_user} -m 700 $${SSH_DIR}
 fi
-
-echo "${ssh_pubkey}" > $${SSH_DIR}/authorized_keys
-chmod 600 $${SSH_DIR}/authorized_keys
+echo "${ssh_pubkey}" | install -o ${deploy_user} -g ${deploy_user} -m 600 /dev/stdin $${SSH_DIR}/authorized_keys