#!/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
# set ssh config to disable root login over ssh
augtool -s set /files/etc/ssh/sshd_config/PasswordAuthentication no
augtool -s set /files/etc/ssh/sshd_config/PermitRootLogin no
augtool -s set /files/etc/ssh/ssh_config/PasswordAuthentication no
# set password for root
echo -e "$DIB_PASSWORD\n$DIB_PASSWORD\n" | passwd
