#!/usr/bin/env bash # Script for initial setup of Debian(-based) distributions # Must be run with root privileges # Before running the script, copy ssh public key file to root user with ssh-copy-id set -Eeuo pipefail trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR USERNAME="cuqmbr" apt-get update && apt-get upgrade -y apt-get install doas -y useradd --create-home --shell /bin/bash "${USERNAME}" passwd "${USERNAME}" echo 'permit persist cuqmbr as root' > /etc/doas.conf mkdir "/home/${USERNAME}/.ssh" cp .ssh/authorized_keys "/home/${USERNAME}/.ssh/" echo 'alias sudo=doas' > "/home/${USERNAME}/.bash_aliases" chown -R "{$USERNAME}:${USERNAME}" "/home/${USERNAME}/" sed -i -e 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config systemctl reload sshd