2024-12-06 17:06:04 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SUDOER_PSW=
|
|
|
|
|
|
|
|
function restofscript(){
|
2024-12-06 18:04:58 -05:00
|
|
|
USERNAMETOADD=
|
|
|
|
PASSWORDTOADD=
|
|
|
|
PUBKEYCONTENT=
|
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 18:23:59 -05:00
|
|
|
cd /home/${USERNAMETOADD}
|
2024-12-06 17:06:04 -05:00
|
|
|
mkdir .ssh
|
|
|
|
pushd .ssh
|
2024-12-06 20:19:28 -05:00
|
|
|
touch authorized_keys
|
2024-12-06 17:06:04 -05:00
|
|
|
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 17:06:04 -05:00
|
|
|
}
|
|
|
|
|
2024-12-06 18:04:58 -05:00
|
|
|
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
|
|
|
|
exit
|