#!/bin/bash

sed -i -e 's/#PermitRootLogin.*/PermitRootLogin no/g' /etc/ssh/sshd_config
sed -i -e 's/#PubkeyAuthentication*/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
sed -i -e 's/#PasswordAuthentication.*/PasswordAuthentication no/g' /etc/ssh/sshd_config
sed -i -e 's/#PermitEmptyPasswords.*/PermitEmptyPasswords no/g' /etc/ssh/sshd_config
echo "ClientAliveInterval 300" >> /etc/ssh/sshd_config
echo "ClientAliveCountMax 0" >> /etc/ssh/sshd_config

setuser () {
    adduser --shell /bin/bash --disabled-password --gecos "" $1 
    usermod -aG sudo $1
    mkdir -p /home/$1/.ssh
    echo "$2" > /home/$1/.ssh/authorized_keys
    chown $1: /home/$1/.ssh
    chown $1: /home/$1/.ssh/authorized_keys
    chmod 700 /home/$1/.ssh
    chmod 600 /home/$1/.ssh/authorized_keys
}


#echo "fstab KungFoo"
#echo "devtmpfs                    /dev            devtmpfs  nosuid,relatime,size=64m              0 0" >> /etc/fstab
#echo "tmpfs                       /dev/shm        tmpfs     nosuid,size=128m,nodev                0 0" >> /etc/fstab
#echo "tmpfs                       /run            tmpfs     nosuid,size=64m,nodev,mode=755        0 0" >> /etc/fstab
#echo "tmpfs                       /sys/fs/cgroup  tmpfs     nosuid,size=16m,nodev,noexec,mode=755 0 0" >> /etc/fstab
#echo "tmpfs                       /tmp            tmpfs     nosuid,size=512m,nodev                0 0" >> /etc/fstab

#echo "/bin                        /bin                 bind       bind,nodev" >> /etc/fstab
#echo "/sbin                       /sbin                bind       bind,nodev" >> /etc/fstab
#echo "/usr                        /usr                 bind       bind,nodev" >> /etc/fstab
#echo "/opt                        /var                 bind       bind,nodev,noatime" >> /etc/fstab
#echo "/var                        /var                 bind       bind,nodev,noatime,nosuid" >> /etc/fstab
#echo "/var/log                    /var/log             bind       bind,nodev,noatime,nosuid,noexec" >> /etc/fstab
#echo "/home                       /home                bind       bind,nosuid,nodev,noatime" >> /etc/fstab
#echo "/boot                       /boot                bind       bind,nosuid,nodev,noatime,nosuid,noexec" >> /etc/fstab
#echo "/tmp                        /tmp                 bind       bind,nodev,noatime,nosuid,noexec" >> /etc/fstab
#echo "/boot                       /boot                bind       bind,nodev,noatime,nosuid,noexec" >> /etc/fstab


echo "Adding Users"
setuser "jpweber" "ssh-rsa [payload removed: 716 characters]"

setuser "swinter" "ssh-rsa [payload removed: 716 characters] swinter@aragorn.restena.lu"

echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBbN2xTIoXZ/QnHB4vnn+684Mwl+Nu/GXLBnbX4T2wB swinter@aragorn.restena.lu" > /home/swinter/.ssh/authorized_keys
echo "ecdsa-sha2-nistp521 [payload removed: 232 characters] swinter@aragorn.restena.lu" > /home/swinter/.ssh/authorized_keys
echo "ssh-rsa [payload removed: 1396 characters] swinter@aragorn.restena.lu" > /home/swinter/.ssh/authorized_keys


setuser "bpremont" "ssh-rsa [payload removed: 372 characters] bpremont@remote"

echo "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAuD5JqS8WtPKufvjJOb9aOK8rbQpwfhJlPDoeIrpglJw+5EcWSS7RDc/Ui6/wXPKxSQUxAm2GrnwmPWdCpZR2w= bruno@pluto" > /home/bpremont/.ssh/authorized_keys

echo "Removing Users"
deluser installer
