deployment/scripts/serviceaccount.sh

20 lines
455 B
Bash
Raw Normal View History

#!/bin/bash
USERNAMETOADD=
PASSWORDTOADD=
PUBKEYCONTENT=
SUDOER_PSW=
function restofscript(){
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
popd
chown -R "${USERNAMETOADD}:${USERNAMETOADD}' .ssh
}
echo "${SUDOER_PSW}" | sudo -S restofscript