it was the newline

This commit is contained in:
adam 2024-12-06 20:58:44 -05:00
parent d7ad1aff9d
commit 84c023783f

View File

@ -5,25 +5,15 @@ SUDOER_PSW=
function restofscript(){ function restofscript(){
USERNAMETOADD= USERNAMETOADD=
PASSWORDTOADD= PASSWORDTOADD=
echo "hello, $(whoami)"
useradd -m -s /bin/bash ${USERNAMETOADD} useradd -m -s /bin/bash ${USERNAMETOADD}
echo "user added"
echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd echo "${USERNAMETOADD}:${PASSWORDTOADD}" | chpasswd
echo "password updated"
loginctl enable-linger ${USERNAMETOADD} loginctl enable-linger ${USERNAMETOADD}
echo "linger enabled"
mkdir /home/${USERNAMETOADD}/.ssh mkdir /home/${USERNAMETOADD}/.ssh
echo "user has .ssh/"
touch /home/${USERNAMETOADD}/authorized_keys touch /home/${USERNAMETOADD}/authorized_keys
echo "user has .ssh/authorized keys"
cat ssh.pub >> /home/${USERNAMETOADD}/.ssh/authorized_keys cat ssh.pub >> /home/${USERNAMETOADD}/.ssh/authorized_keys
echo "authorized keys should accept ssh.pub"
chmod 600 /home/${USERNAMETOADD}/authorized_keys chmod 600 /home/${USERNAMETOADD}/authorized_keys
echo "authorized keys should be mode 600"
chown -R "${USERNAMETOADD}:${USERNAMETOADD}" /home/${USERNAMETOADD}/.ssh chown -R "${USERNAMETOADD}:${USERNAMETOADD}" /home/${USERNAMETOADD}/.ssh
echo "correct user should own his .ssh directory. done!"
} }
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript" echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
echo "restofscript should be done, exiting."
exit exit