mirror of
https://github.com/kevinveenbirkenbach/linux-image-manager.git
synced 2024-11-14 03:21:03 +01:00
Optimized ssh copying
This commit is contained in:
parent
d8b0ca6906
commit
3c4163008c
@ -274,20 +274,25 @@ if [ "$os" != "manjaro" ]
|
|||||||
question "Should the ssh-key be copied to the image?(y/N)" && read -r copy_ssh_key || error
|
question "Should the ssh-key be copied to the image?(y/N)" && read -r copy_ssh_key || error
|
||||||
if [ "$copy_ssh_key" == "y" ]
|
if [ "$copy_ssh_key" == "y" ]
|
||||||
then
|
then
|
||||||
info "Copy ssh key to target..." &&
|
correct_ssh_key_path=false;
|
||||||
origin_user_rsa_pub="$origin_user_home"".ssh/id_rsa.pub" || error
|
while [ "$correct_ssh_key_path" != true ]
|
||||||
if [ -f "$origin_user_rsa_pub" ]
|
do
|
||||||
then
|
question "Whats the absolut path to the ssh key:" && read -r origin_user_rsa_pub || error
|
||||||
mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created."
|
if [ -f "$origin_user_rsa_pub" ]
|
||||||
cat "$origin_user_rsa_pub" > "$target_authorized_keys" &&
|
then
|
||||||
target_authorized_keys_content=$(cat "$target_authorized_keys") &&
|
correct_ssh_key_path=true;
|
||||||
info "$target_authorized_keys contains the following: $target_authorized_keys_content" &&
|
else
|
||||||
chown -vR 1000 "$target_user_ssh_folder_path" &&
|
warning "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist."
|
||||||
chmod -v 700 "$target_user_ssh_folder_path" &&
|
fi
|
||||||
chmod -v 600 "$target_authorized_keys" || error
|
done
|
||||||
else
|
info "Copy ssh key to target..."
|
||||||
warning "The ssh key \"$origin_user_rsa_pub\" can't be copied to \"$target_authorized_keys\" because it doesn't exist."
|
mkdir -v "$target_user_ssh_folder_path" || warning "Folder \"$target_user_ssh_folder_path\" exists. Can't be created."
|
||||||
fi
|
cat "$origin_user_rsa_pub" > "$target_authorized_keys" &&
|
||||||
|
target_authorized_keys_content=$(cat "$target_authorized_keys") &&
|
||||||
|
info "$target_authorized_keys contains the following: $target_authorized_keys_content" &&
|
||||||
|
chown -vR 1000 "$target_user_ssh_folder_path" &&
|
||||||
|
chmod -v 700 "$target_user_ssh_folder_path" &&
|
||||||
|
chmod -v 600 "$target_authorized_keys" || error
|
||||||
else
|
else
|
||||||
info "Skipped SSH-key copying.."
|
info "Skipped SSH-key copying.."
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user