adam
88419c8985
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
20 lines
609 B
Bash
20 lines
609 B
Bash
#!/bin/bash
|
|
|
|
SUDOER_PSW=
|
|
|
|
function restofscript(){
|
|
USERNAMETOADD=
|
|
PASSWORDTOADD=
|
|
useradd -m -s /bin/bash ${USERNAMETOADD}
|
|
echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd
|
|
loginctl enable-linger ${USERNAMETOADD}
|
|
mkdir /home/${USERNAMETOADD}/.ssh
|
|
touch /home/${USERNAMETOADD}/.ssh/authorized_keys
|
|
cat ssh.pub >> /home/${USERNAMETOADD}/.ssh/authorized_keys
|
|
chmod 600 /home/${USERNAMETOADD}/authorized_keys
|
|
chown -R "${USERNAMETOADD}:${USERNAMETOADD}" /home/${USERNAMETOADD}/.ssh
|
|
}
|
|
|
|
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
|
|
exit
|