deployment/scripts/serviceaccount.sh

22 lines
540 B
Bash
Raw Normal View History

#!/bin/bash
SUDOER_PSW=
function restofscript(){
2024-12-06 18:04:58 -05:00
USERNAMETOADD=
PASSWORDTOADD=
PUBKEYCONTENT=
useradd -m -s /bin/bash ${USERNAMETOADD}
echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd
loginctl enable-linger ${USERNAMETOADD}
cd ~/home/${USERNAMETOADD}
mkdir .ssh
pushd .ssh
echo ${PUBKEYCONTENT} > authorized_keys
2024-12-06 18:04:58 -05:00
chmod 600 authorized_keys
popd
2024-12-06 18:04:58 -05:00
chown -R '${USERNAMETOADD}:${USERNAMETOADD}' .ssh
}
2024-12-06 18:04:58 -05:00
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
exit