diff options
| author | Your Name <you@example.com> | 2026-02-07 19:58:55 +0800 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-02-07 19:58:55 +0800 |
| commit | d1cebc658174a16014c2a3847bdf55bb3553b7fb (patch) | |
| tree | 843abd31aabf15bdf9c78314c69922a5df586531 | |
| parent | 7bd52ea1ae10870cc2ff8aa5c237679c30ffda72 (diff) | |
more robust for ssh floods
| -rw-r--r-- | docs (renamed from README) | 3 | ||||
| -rw-r--r-- | sshd_config | 4 | ||||
| -rwxr-xr-x | start_container.sh | 2 |
3 files changed, 9 insertions, 0 deletions
| @@ -55,5 +55,8 @@ Cleanup: | |||
| 55 | Logs: | 55 | Logs: |
| 56 | podman logs -f cgit | 56 | podman logs -f cgit |
| 57 | 57 | ||
| 58 | Processes: | ||
| 59 | podman exec cgit ps aux | ||
| 60 | |||
| 58 | Shell: | 61 | Shell: |
| 59 | podman exec -it cgit sh | 62 | podman exec -it cgit sh |
diff --git a/sshd_config b/sshd_config index ab4c469..5d31e36 100644 --- a/sshd_config +++ b/sshd_config | |||
| @@ -3,4 +3,8 @@ PermitRootLogin prohibit-password | |||
| 3 | PasswordAuthentication no | 3 | PasswordAuthentication no |
| 4 | PubkeyAuthentication yes | 4 | PubkeyAuthentication yes |
| 5 | AuthorizedKeysFile /git/.ssh/authorized_keys | 5 | AuthorizedKeysFile /git/.ssh/authorized_keys |
| 6 | # Max 3 concurrent unauthenticated connections, drop 50% above that, hard cap at 10 | ||
| 7 | MaxStartups 3:50:10 | ||
| 8 | # Kill unauthenticated connections after 15 seconds | ||
| 9 | LoginGraceTime 15 | ||
| 6 | Subsystem sftp /usr/lib/ssh/sftp-server | 10 | Subsystem sftp /usr/lib/ssh/sftp-server |
diff --git a/start_container.sh b/start_container.sh index 25fcb10..2299390 100755 --- a/start_container.sh +++ b/start_container.sh | |||
| @@ -33,6 +33,7 @@ podman run -d \ | |||
| 33 | --network ${NETWORK} \ | 33 | --network ${NETWORK} \ |
| 34 | --ip ${PRIVATE_IP} \ | 34 | --ip ${PRIVATE_IP} \ |
| 35 | --cap-add=NET_ADMIN \ | 35 | --cap-add=NET_ADMIN \ |
| 36 | --pids-limit=100 \ | ||
| 36 | --env-file "$(dirname "$0")/config.env" \ | 37 | --env-file "$(dirname "$0")/config.env" \ |
| 37 | -v ${CONTAINER_NAME}_data:/data \ | 38 | -v ${CONTAINER_NAME}_data:/data \ |
| 38 | -v /git:/git \ | 39 | -v /git:/git \ |
| @@ -40,6 +41,7 @@ podman run -d \ | |||
| 40 | 41 | ||
| 41 | # Setup public IP | 42 | # Setup public IP |
| 42 | sleep 2 | 43 | sleep 2 |
| 44 | # Get the container's network interface name (e.g. eth0) | ||
| 43 | IFACE=$(podman exec ${CONTAINER_NAME} sh -c "ip -o link | grep -v lo | head -1 | cut -d: -f2 | tr -d ' ' | cut -d@ -f1") | 45 | IFACE=$(podman exec ${CONTAINER_NAME} sh -c "ip -o link | grep -v lo | head -1 | cut -d: -f2 | tr -d ' ' | cut -d@ -f1") |
| 44 | podman exec ${CONTAINER_NAME} ip addr add ${PUBLIC_IP}/32 dev ${IFACE} | 46 | podman exec ${CONTAINER_NAME} ip addr add ${PUBLIC_IP}/32 dev ${IFACE} |
| 45 | ip route add ${PUBLIC_IP}/32 via ${PRIVATE_IP} | 47 | ip route add ${PUBLIC_IP}/32 via ${PRIVATE_IP} |
