1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-15 11:22:43 +03:00

Handle error when setting ssh key

Avoid create a /.ssh dir if user does not exist.
This commit is contained in:
Natanael Copa 2023-05-08 21:53:19 +02:00
parent 7be3b198fb
commit de66c6049e

View File

@ -218,6 +218,10 @@ init__set_hostname() {
init__set_ssh_keys() {
local user="$CLOUD_USER"
local pwent="$(getent passwd "$user")"
if [ -z "$pwent" ]; then
log err "Failed to find user $user"
return 1
fi
local group=$(echo "$pwent" | cut -d: -f4)
local ssh_dir="${ROOT}$(echo "$pwent" | cut -d: -f6)/.ssh"
local keys_file="$ssh_dir/authorized_keys"