deployment/scripts/serviceaccount.sh

23 lines
561 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}
2024-12-06 18:23:59 -05:00
cd /home/${USERNAMETOADD}
mkdir .ssh
pushd .ssh
2024-12-06 20:19:28 -05:00
touch authorized_keys
popd
2024-12-06 20:19:28 -05:00
cat ssh.pub >> .ssh/authorized_keys
chmod 600 authorized_keys
2024-12-06 18:20:35 -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