diff --git a/integration/scripts/files/elements/root-passwd/README.rst b/integration/scripts/files/elements/root-passwd/README.rst new file mode 100644 index 0000000000..0610a89571 --- /dev/null +++ b/integration/scripts/files/elements/root-passwd/README.rst @@ -0,0 +1,5 @@ +This element assigns a password to the root account in the image and enables +password login via ssh. + +This is useful when booting outside of a cloud environment (e.g. manually via +kvm) and for testing. diff --git a/integration/scripts/files/elements/root-passwd/post-install.d/99-setup b/integration/scripts/files/elements/root-passwd/post-install.d/99-setup new file mode 100755 index 0000000000..1c93f459aa --- /dev/null +++ b/integration/scripts/files/elements/root-passwd/post-install.d/99-setup @@ -0,0 +1,11 @@ +#!/bin/bash +if [ -z "$DIB_PASSWORD" ]; then + echo "Error during setup password for root" + exit 1 +fi +sed -i "s/disable_root: true/disable_root: false/" /etc/cloud/cloud.cfg +install-packages augeas-tools openssh-server openssh-client +augtool -s set /files/etc/ssh/sshd_config/PasswordAuthentication yes +augtool -s set /files/etc/ssh/sshd_config/PermitRootLogin yes +augtool -s set /files/etc/ssh/ssh_config/PasswordAuthentication yes +echo -e "$DIB_PASSWORD\n$DIB_PASSWORD\n" | passwd diff --git a/integration/scripts/functions_qemu b/integration/scripts/functions_qemu index e6c00c91db..cfc9b32ac1 100644 --- a/integration/scripts/functions_qemu +++ b/integration/scripts/functions_qemu @@ -13,6 +13,7 @@ function build_guest_image() { local image_output=$5 local image_type=${image_output##*.} local working_dir=$(dirname ${image_output}) + local root_password=${TROVE_ROOT_PASSWORD} local elementes="base vm" local trove_elements_path=${PATH_TROVE}/integration/scripts/files/elements @@ -60,6 +61,11 @@ function build_guest_image() { elementes="$elementes guest-agent" elementes="$elementes ${guest_os}-docker" + if [[ -n ${root_password} ]]; then + elementes="$elementes root-passwd" + export DIB_PASSWORD=${root_password} + fi + # Build the image disk-image-create -x \ -a amd64 \