create user with sudo priviliges

This commit is contained in:
Ray Elliott 2020-03-19 19:07:07 +00:00
parent e7e1a2b990
commit 59e3fe422d
3 changed files with 32 additions and 0 deletions

2
config.sh Normal file
View File

@ -0,0 +1,2 @@
export _url="hugo-skeleton.home"
export _user='ray'

16
deploy-script.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "deploy-script.sh: Error - Must supply script as argument"
exit
else
_script="$1"
fi
. ./config.sh
cat config.sh "$_script" | ssh root@"$_url" "cat >/tmp/deploy-script.sh"
ssh root@"$_url" '/bin/bash /tmp/deploy-script.sh'
ssh root@"$_url" '/bin/bash -c "rm /tmp/deploy-script.sh"'

14
user.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
useradd -m -s /bin/bash "$_user"
groupadd sudo
usermod -aG sudo "$_user"
mkdir /home/"$_user"/.ssh
cp /root/.ssh/authorized_keys /home/"$_user"/.ssh/
chown "$_user": /home/"$_user"/.ssh/authorized_keys
passwd -d "$_user"
chage -d 0 "$_user"
# TODO test apt-get is used
apt-get update && apt-get -y upgrade && apt-get -y install sudo
# TODO ensure group sudo is allowed sudo