summaryrefslogtreecommitdiff
path: root/fortress.sh
blob: 4df09214e702a029b2d5f01bbb9c2aa0c0c53062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# fortress_setup_ubuntu.sh - secure SSH fortress on Ubuntu with UFW

set -e

bouncer_ip="38.102.127.173"

echo "Updating package lists..."
sudo apt update

echo "Installing UFW if not present..."
sudo apt install -y ufw

echo "Setting default UFW policies..."
sudo ufw default deny incoming
sudo ufw default allow outgoing

echo "Allowing SSH only from bouncer ($bouncer_ip)..."
sudo ufw allow from $bouncer_ip to any port 22 proto tcp comment 'Allow SSH from bouncer'

echo "Allowing inbound HTTP/HTTPS..."
sudo ufw allow 80/tcp comment 'Allow HTTP'
sudo ufw allow 443/tcp comment 'Allow HTTPS'

echo "Enabling UFW..."
sudo ufw --force enable

echo "UFW Status:"
sudo ufw status verbose

echo "SSH fortress is active! Only $bouncer_ip can connect via SSH."