matrix-ops/iaas-enable-root.sh
Patrik Lundin 16a6a67fd1
Make debian iaas prepare scripts handle ubuntu
Now ubuntu also uses the updated way of preparing iaas instances like
debian did before, actually the debian scripts have been remade to also
handle ubuntu so we use a common code path.

Usage (what scripts to call) stay the same, but the underlying
operations takes less logins to complete.
2022-11-14 12:54:08 +01:00

18 lines
444 B
Bash
Executable file

#!/usr/bin/env bash
#
# This script is called from prepare-iaas-$os after logging in via ssh as
# the default user existing in cloud images
#
set -ex
os=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
if [ "$os" != "ubuntu" ] && [ "$os" != "debian" ]; then
echo "unsupported os: '$os'"
exit 1
fi
sudo cp -r /home/"$os"/.ssh /root/
sudo chown -R root:root /root/.ssh
sudo chmod 700 /root/.ssh
sudo chmod 600 /root/.ssh/authorized_keys