Skip to content

Instantly share code, notes, and snippets.

@dargmuesli
Last active November 12, 2020 16:39
Show Gist options
  • Save dargmuesli/645a4d51ab1806ebfb3329fb05637318 to your computer and use it in GitHub Desktop.
Save dargmuesli/645a4d51ab1806ebfb3329fb05637318 to your computer and use it in GitHub Desktop.
Initial setup script for Hetzner servers.
# Run
# wget https://gist.githubusercontent.com/dargmuesli/645a4d51ab1806ebfb3329fb05637318/raw -O hetzner-start.sh && chmod +x hetzner-start.sh && ./hetzner-start.sh
sudo apt-get update \
&& sudo apt-get -y dist-upgrade \
&& sudo apt-get -y install git vim
passwd
echo "username: "
read username
useradd -U -G users,sudo -m -s /bin/bash "$username"
passwd "$username"
cp ~/.ssh/ /home/"$username"/.ssh -r
chown "$username":"$username" /home/"$username"/.ssh -R
sed -i "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config
sed -i "s/\#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config
/etc/init.d/ssh reload
vim /etc/hostname
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment