Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install fail2ban on Debian Linux
#!/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!"
@jeffrade
Copy link
Author

jeffrade commented Aug 17, 2020

This script now has a home at https://github.com/jeffrade/proxy-server

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