Last active
December 8, 2018 19:36
-
-
Save dbtlr/bf57c681691e3981993b579e042121a4 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
echo $NEW_USER | |
timedatectl set-timezone UTC | |
apt-get update | |
apt-get dist-upgrade -y | |
apt-get upgrade -y | |
useradd $NEW_USER | |
mkdir /home/$NEW_USER | |
mkdir /home/$NEW_USER/.ssh | |
chmod 700 /home/$NEW_USER/.ssh | |
usermod -s /bin/bash $NEW_USER | |
echo "$PUBLIC_KEY" >> /home/$NEW_USER/.ssh/authorized_keys | |
chmod 400 /home/$NEW_USER/.ssh/authorized_keys | |
chown $NEW_USER:$NEW_USER /home/$NEW_USER -R | |
usermod -aG sudo $NEW_USER | |
sed 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config >> /tmp/sshd_config1 | |
sed 's/PasswordAuthentication yes/PasswordAuthentication no/g' /tmp/sshd_config1 >> /tmp/sshd_config2 | |
rm /etc/ssh/sshd_config | |
mv /tmp/sshd_config2 /etc/ssh/sshd_config | |
# Install OH My ZSH | |
apt-get install -y zsh | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
# Change default theme | |
sed 's/robbyrussell/tjkirch/g' ~/.zshrc >> ~/.zshrc1 | |
rm ~/.zshrc | |
mv ~/.zshrc1 ~/.zshrc | |
source ~/.zshrc | |
service ssh restart | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on this guide.
Basically, log into a server and run this: