Skip to content

Instantly share code, notes, and snippets.

@dbtlr
Last active December 8, 2018 19:36
Show Gist options
  • Save dbtlr/bf57c681691e3981993b579e042121a4 to your computer and use it in GitHub Desktop.
Save dbtlr/bf57c681691e3981993b579e042121a4 to your computer and use it in GitHub Desktop.
#!/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
@dbtlr
Copy link
Author

dbtlr commented Apr 28, 2017

Based on this guide.

Basically, log into a server and run this:

curl -sSL https://gist.githubusercontent.com/dbtlr/bf57c681691e3981993b579e042121a4/raw/ed76dd5325143213f63ba3d65330595b01cb3353/first-10-minutes.sh | NEW_USER=user PUBLIC_KEY="{your public key)" sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment