#!/bin/bash
# secrets_username
# secrets_userpassword

[[ -n $secrets_username ]] || exit

id -u $secrets_username || {
	useradd -d /home/$secrets_username -m $secrets_username
}

[[ -n $secrets_userpassword ]] && {
        echo $secrets_username:$secrets_userpassword | chpasswd
}

su - $secrets_username <<-EOF
mkdir -p /home/$secrets_username/.ssh
ssh-keygen -f /home/$secrets_username/.ssh/id_rsa -N ''
EOF
