2024-12-06 17:06:04 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SUDOER_PSW=
|
|
|
|
|
|
|
|
function restofscript(){
|
2024-12-06 18:04:58 -05:00
|
|
|
USERNAMETOADD=
|
|
|
|
PASSWORDTOADD=
|
2024-12-06 17:06:04 -05:00
|
|
|
useradd -m -s /bin/bash ${USERNAMETOADD}
|
|
|
|
echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd
|
|
|
|
loginctl enable-linger ${USERNAMETOADD}
|
2024-12-06 20:39:16 -05:00
|
|
|
mkdir /home/${USERNAMETOADD}/.ssh
|
|
|
|
touch /home/${USERNAMETOADD}/authorized_keys
|
|
|
|
cat ssh.pub >> /home/${USERNAMETOADD}/.ssh/authorized_keys
|
|
|
|
chmod 600 /home/${USERNAMETOADD}/authorized_keys
|
|
|
|
chown -R "${USERNAMETOADD}:${USERNAMETOADD}" /home/${USERNAMETOADD}/.ssh
|
2024-12-06 17:06:04 -05:00
|
|
|
}
|
|
|
|
|
2024-12-06 18:04:58 -05:00
|
|
|
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
|
2024-12-06 20:56:32 -05:00
|
|
|
exit
|