Skip to content

Instantly share code, notes, and snippets.

Last active May 20, 2019
What would you like to do?
read -s -p 'user:' user
adduser --gecos '' --ingroup sudo "$user"
install -o "$user" -g sudo -m 700 -d "/home/$user/.ssh"
install -o "$user" -g sudo -m 644 /dev/null "/home/$user/.ssh/authorized_keys2"
cat </root/.ssh/authorized_keys2 >>"/home/$user/.ssh/authorized_keys2"
rm /root/.ssh/authorized_keys2
sed -i 's/^\(PermitRootLogin \)yes/\1no/' /etc/ssh/sshd_config
sed -i 's/^\(PasswordAuthentication \)yes/\1no/' /etc/ssh/sshd_config
service ssh restart
apt-get update
apt-get upgrade -y
apt-get install fail2ban -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment