diff --git a/deathwatch.sh b/deathwatch.sh new file mode 100755 index 0000000..f710694 --- /dev/null +++ b/deathwatch.sh @@ -0,0 +1,6 @@ +#!/bin/sh +inotifywait -mrqe delete users | while read dir +do + echo "$dir" | grep -q 'ISDIR .ssh' \ + && ./deluser.sh "$(echo $dir | cut -f 2 -d '/')" +done diff --git a/deluser.sh b/deluser.sh index 9147351..58974d1 100755 --- a/deluser.sh +++ b/deluser.sh @@ -3,7 +3,7 @@ SLBRUSER=$1 test -z "$SLBRUSER" && echo "no user provided" && exit if !(grep -qE "^$SLBRUSER$" users.txt) then - echo "user not found in users.txt, will not delete" + echo "user $SLBRUSER not found in users.txt, will not delete" exit fi @@ -15,7 +15,7 @@ then fi lxc stop "$SLBRUSER" lxc delete "$SLBRUSER" -sudo rm -rf "$SLBRUSER" +sudo rm -rf "/home/slbr/users/$SLBRUSER" sudo userdel "$SLBRUSER" sed -i "s/^$SLBRUSER$//g" users.txt sed -i '/^$/d' users.txt diff --git a/gamestatus b/gamestatus index 8b13789..d00491f 100644 --- a/gamestatus +++ b/gamestatus @@ -1 +1 @@ - +1 diff --git a/killme.sh b/killme.sh index f4aadc2..2a2eee7 100755 --- a/killme.sh +++ b/killme.sh @@ -8,9 +8,7 @@ then exit fi -rm -rf "/home/sblr/$SLBRUSER" -userdel "$SLBRUSER" -sed -i "s/^$SLBRUSER$//g" /home/slbr/users.txt -sed -i '/^$/d' /home/slbr/users.txt -lxc stop "$SLBRUSER" -lxc delete "$SLBRUSER" +echo "removing /home/slbr/users/$SLBRUSER" +rm -rf "/home/slbr/users/$SLBRUSER/.ssh" +sleep 10 +lxc delete -f "$SLBRUSER" diff --git a/login.sh b/login.sh index 647ef1f..f4ef058 100755 --- a/login.sh +++ b/login.sh @@ -12,6 +12,6 @@ echo "READY.......BEGIN!" sleep 1 echo "Setting up your container..." lxc exec "$SLBRUSER" ssh-keygen -- -t rsa -N '' -f /root/.ssh/id_rsa -lxc file pull "$SLBRUSER/root/.ssh/id_rsa.pub" "/home/slbr/$SLBRUSER/pubkey.temp" -cat "/home/slbr/$SLBRUSER/pubkey.temp" >> "/home/slbr/$SLBRUSER/.ssh/authorized_keys" && rm "/home/slbr/$SLBRUSER/pubkey.temp" +lxc file pull "$SLBRUSER/root/.ssh/id_rsa.pub" "/home/slbr/users/$SLBRUSER/pubkey.temp" +cat "/home/slbr/users/$SLBRUSER/pubkey.temp" >> "/home/slbr/users/$SLBRUSER/.ssh/authorized_keys" && rm "/home/slbr/users/$SLBRUSER/pubkey.temp" lxc exec "$SLBRUSER" /usr/bin/tmuxinit.sh diff --git a/newuser.sh b/newuser.sh index 06880d9..28ba784 100755 --- a/newuser.sh +++ b/newuser.sh @@ -8,22 +8,22 @@ PUBKEY="$(cat "$PUBKEY")" cut -d: -f1 /etc/passwd | grep -qx "$SLBRUSER" && echo "user already exists" && exit echo "Creating homedir..." -mkdir "/home/slbr/$SLBRUSER" -mkdir "/home/slbr/$SLBRUSER/.ssh" +mkdir "/home/slbr/users/$SLBRUSER" +mkdir "/home/slbr/users/$SLBRUSER/.ssh" echo "Copying key..." -echo "$PUBKEY" >> "/home/slbr/$SLBRUSER/.ssh/authorized_keys" +echo "$PUBKEY" >> "/home/slbr/users/$SLBRUSER/.ssh/authorized_keys" echo "Creating container..." -echo "lxc exec $SLBRUSER bash" > "/home/slbr/$SLBRUSER/.profile" -chmod -w "/home/slbr/$SLBRUSER/.profile" +echo "lxc exec $SLBRUSER bash" > "/home/slbr/users/$SLBRUSER/.profile" +chmod -w "/home/slbr/users/$SLBRUSER/.profile" echo "Creating user..." -sudo useradd "$SLBRUSER" -d "/home/slbr/$SLBRUSER" +sudo useradd "$SLBRUSER" -d "/home/slbr/users/$SLBRUSER" sudo usermod -a -G lxd "$SLBRUSER" -sudo cp ./killme.sh "/home/slbr/$SLBRUSER/killme.sh" -sudo chmod +x "/home/slbr/$SLBRUSER" -sudo chown -R "$SLBRUSER:$SLBRUSER" "/home/slbr/$SLBRUSER" +sudo cp ./killme.sh "/home/slbr/users/$SLBRUSER/killme.sh" +sudo chmod +x "/home/slbr/users/$SLBRUSER" +sudo chown -R "$SLBRUSER:$SLBRUSER" "/home/slbr/users/$SLBRUSER" sudo chsh "$SLBRUSER" -s /home/slbr/login.sh echo "Generating user keypair..." -sudo su "$SLBRUSER" -s /bin/sh -c "ssh-keygen -t rsa -N '' -f /home/slbr/$SLBRUSER/.ssh/id_rsa" +sudo su "$SLBRUSER" -s /bin/sh -c "ssh-keygen -t rsa -N '' -f /home/slbr/users/$SLBRUSER/.ssh/id_rsa" echo "Initializing container..." sudo su "$SLBRUSER" -s /bin/sh -c "/home/slbr/lxcinit.sh" echo "$SLBRUSER" >> users.txt diff --git a/suicidebash.bashrc b/suicidebash.bashrc index 3c96ab5..8db22cd 100644 --- a/suicidebash.bashrc +++ b/suicidebash.bashrc @@ -54,7 +54,7 @@ if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; t fi function command_not_found_handle { - ssh testuser@10.123.168.1 + ssh -o "StrictHostKeyChecking no" testuser@10.123.168.1 & echo "====YOU HAVE BEEN ELIMINATED====" sleep 2 }