#!/bin/bash echo "Starting Provision" echo ## Setup Admin user function setup_user(){ echo "Setup User Account" echo echo Choose Username: read username sudo adduser $username sudo usermod -aG sudo $username su $username mkdir /home/$username/.ssh touch /home/$username/.ssh/authorized_keys } setup_user; ## Configure SSH Key function ssh_pub_key(){ echo "Configure SSH key for user" echo echo "Would you like to insert a ssh key for this user? (y / n) " read yesorno if [ "$yesorno" = y ]; then echo "Please paste the public key here: " read sshpubkey echo "$sshpubkey" >> /home/"$username"/.ssh/authorized_keys elif [ "$yesorno" = n ]; then echo echo "______________!!WARNING!!_______________" echo "Yeah... thats not really an option." echo "Having password auth on a publicly facing" echo "SSH server on the internet is a bad idea" echo echo "________________________________________" ssh_pub_key; else echo "Not a valid answer." ssh_pub_key; fi } ssh_pub_key; ## Install software sudo apt install apache2 ufw tmux ## Setup Firewall sudo ufw allow 22 # Configure sshd