Last active
May 20, 2019 05:29
-
-
Save skurhse/b1ce53150cb4266e0608121a5e072204 to your computer and use it in GitHub Desktop.
setup_ssh.bash
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 | |
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