#!/bin/bash ######################################################## # T-Pot Community Edition post install script # # Ubuntu server 14.04, x64 # # # # v0.18 by mo, DTAG, 2014-12-18 # ######################################################## # Let's make sure there is a warning if running for a second time if [ -f install.log ]; then fuECHO "### Running more than once may complicate things. Erase install.log if you are really sure." exit 1; fi # Let's log for the beauty of it set -e exec 2> >(tee "install.err") exec > >(tee "install.log") # Let's create a function for colorful output fuECHO () { local myRED=1 local myWHT=7 tput setaf $myRED echo $1 "$2" tput setaf $myWHT } # Let's modify the sources list sed -i '/cdrom/d' /etc/apt/sources.list # Let's add the docker repository fuECHO "### Adding docker repository." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 tee /etc/apt/sources.list.d/docker.list < /data/puppet/name.conf # Let's patch sshd_config fuECHO "### Patching sshd_config to listen on port 64295 and deny password authentication." sed -i 's#Port 22#Port 64295#' /etc/ssh/sshd_config sed -i 's#\#PasswordAuthentication yes#PasswordAuthentication no#' /etc/ssh/sshd_config # Disable ssh service mv /etc/init/ssh.conf /etc/init/ssh.conf.disable # Let's add the ssh keys #fuECHO "### Adding ssh keys for the admin user." #mkdir -p /home/admin/.ssh/ #tee /home/admin/.ssh/authorized_keys < /dev/tty2; date > /dev/tty2; docker ps > /dev/tty2; echo > /dev/tty2 EOF # Let's add a nice and useful issue text and update rc.local accordingly fuECHO "### Adding a nice and useful issue text and updating rc.local accordingly." tee /etc/issue < /etc/rc.local.new echo "# Let's add the first local ip to the /etc/issue file" >> /etc/rc.local.new echo 'sed -i "s#IP:.*#IP: ""$(hostname -I | awk '"'"'{ print $1 }'"'"')""#" /etc/issue' >> /etc/rc.local.new echo "exit 0" >> /etc/rc.local.new chmod +x /etc/rc.local.new # Final steps fuECHO "### Thanks for your patience. Now rebooting." mv /etc/rc.local.new /etc/rc.local && chage -d 0 tsec && sleep 2 && reboot