Created
June 30, 2019 14:41
-
-
Save jeffrade/fbeb78594ae3459b44b4216043a25595 to your computer and use it in GitHub Desktop.
Install fail2ban on Debian Linux
This file contains hidden or 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/sh -x | |
echo "Starting..." | |
apt-get install -y fail2ban | |
systemctl start fail2ban | |
systemctl enable fail2ban | |
> /etc/fail2ban/jail.local | |
echo "[sshd]" >> /etc/fail2ban/jail.local | |
echo "enabled = true" >> /etc/fail2ban/jail.local | |
echo "port = 22" >> /etc/fail2ban/jail.local | |
echo "filter = sshd" >> /etc/fail2ban/jail.local | |
echo "logpath = /var/log/auth.log" >> /etc/fail2ban/jail.local | |
echo "maxretry = 3" >> /etc/fail2ban/jail.local | |
systemctl restart fail2ban | |
rm -rf $HOME/.ssh | |
mkdir $HOME/.ssh && echo "" >> $HOME/.ssh/authorized_keys | |
chmod go-w $HOME $HOME/.ssh | |
chmod 600 $HOME/.ssh/authorized_keys | |
chown `whoami` $HOME/.ssh/authorized_keys | |
# Use ssh-copy-id to add .ssh/id_rsa.pub from | |
# client machine to remote server https://linux.die.net/man/1/ssh-copy-id | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script now has a home at https://github.com/jeffrade/proxy-server