Addded ssh key auth

This commit is contained in:
sose 2018-09-19 22:43:25 +02:00
parent bfba4730fd
commit 500e51695f
2 changed files with 9 additions and 5 deletions

View File

@ -29,7 +29,7 @@ contact ~ben or sose on tilde.chat (in the #slbr channel) to sign up.
- Once all of your users are created and logged in, run `echo "1" > gamestatus` to start the game.
## TODO
- Handling of ssh keys and/or passwords
- Install-time configuration (setting proper ips, hostname, etc.)
- A goal and a way to check it
This is a ~ work in progress ~

View File

@ -5,15 +5,19 @@ test -z "$SLBRUSER" && echo "no user provided" && exit
echo "Creating homedir..."
mkdir "/home/slbr/$SLBRUSER"
mkdir "/home/slbr/$SLBRUSER/.ssh"
echo "Copying key..."
echo "$PUBKEY" >> "/home/slbr/$SLBRUSER/.ssh/authorized_keys"
echo "$SLBRUSER" >> users
echo "Creating container..."
echo "lxc exec $SLBRUSER bash" > "/home/slbr/$SLBRUSER/.profile"
chmod -w "/home/slbr/$SLBRUSER/.profile"
echo "Creating user..."
sudo useradd "$SLBRUSER" -d "/home/slbr/$SLBRUSER"
sudo usermod -a -G lxd "$SLBRUSER"
sudo chown "$SLBRUSER:$SLBRUSER" "/home/slbr/$SLBRUSER"
sudo chown -R "$SLBRUSER:$SLBRUSER" "/home/slbr/$SLBRUSER"
sudo chsh "$SLBRUSER" -s /home/slbr/login.sh
echo "Creating container..."
echo "Generating user keypair..."
sudo su "$SLBRUSER" -s /bin/sh -c "ssh-keygen -t rsa -N '' -f /home/slbr/$SLBRUSER/.ssh/id_rsa"
echo "Initializing container..."
sudo su "$SLBRUSER" -s /bin/sh -c "/home/slbr/lxcinit.sh"
mkdir "/home/slbr/$SLBRUSER/.ssh"
echo "$PUBKEY" >> "/home/slbr/$SLBRUSER/.ssh/authorized_keys"