Amazon EC2
aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamlSets up Fail2Ban to protect against brute force attacks
#cloud-config
package_update: true
package_upgrade: true
packages:
- fail2ban
- iptables-persistent
write_files:
- path: /etc/fail2ban/jail.local
content: |
[DEFAULT]
bantime = 3600
findtime = 600
maxretry = 5
[sshd]
enabled = true
port = ssh
logpath = /var/log/auth.log
maxretry = 3
[nginx-http-auth]
enabled = true
[nginx-limit-req]
enabled = true
[apache]
enabled = true
[apache-badbots]
enabled = true
runcmd:
- systemctl enable fail2ban
- systemctl start fail2ban
- fail2ban-client statusaws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamldoctl compute droplet create
--image ubuntu-22-04-x64
--size s-1vcpu-1gb
--user-data-file script.yaml
my-dropletgcloud compute instances create
my-instance
--metadata-from-file
user-data=script.yaml