-
-
Save max-mapper/8551202 to your computer and use it in GitHub Desktop.
taco ubuntu server provisioning based on https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-12-04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf '\e[1;34m%b\e[m' "\nUpdating the system...\n" | |
apt-get -y -qq update | |
apt-get -y upgrade | |
NEW_USER=$1 | |
if [ ! -d /home/$NEW_USER ]; then | |
printf '\e[1;34m%b\e[m' "\nCreating user '$NEW_USER'...\n" | |
adduser --gecos "" $NEW_USER | |
mkdir /home/$NEW_USER/.ssh | |
chmod 700 /home/$NEW_USER/.ssh | |
printf '\e[1;34m%b\e[m' "\nAdding ssh keys to $NEW_USER...\n" | |
cp /root/.ssh/authorized_keys /home/$NEW_USER/.ssh/ | |
chmod 400 /home/$NEW_USER/.ssh/authorized_keys | |
chown $NEW_USER:$NEW_USER /home/$NEW_USER -R | |
printf '\e[1;34m%b\e[m' "\nGranting sudo rights to $NEW_USER\n" | |
adduser $NEW_USER sudo | |
# make ssh a little more secure | |
printf '\e[1;34m%b\e[m' "\nDisabling ssh root login...\n" | |
sed -e 's/^PermitRootLogin .*$/PermitRootLogin no/' -i /etc/ssh/sshd_config | |
sed -e 's/#\{0,1\}PasswordAuthentication .*$/PasswordAuthentication no/' -i /etc/ssh/sshd_config | |
reload ssh | |
fi | |
printf '\e[1;34m%b\e[m' "\nCreating user 'taco'...\n" | |
adduser --system --group --gecos "" taco | |
printf '\e[1;34m%b\e[m' "\nSetting up basic firewall...\n" | |
apt-get -y -qq install ufw | |
ufw allow ssh | |
ufw allow http | |
ufw allow https | |
ufw allow 8080 | |
echo "y" | ufw enable | |
ufw status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment