99
1010jobs :
1111 test-on-distro :
12- # Use a matrix to run the same job on both Debian and Ubuntu
1312 strategy :
13+ # Run the test on both Debian and multiple Ubuntu versions
1414 matrix :
15- distro : [debian:12, ubuntu:22.04]
15+ distro : [debian:12, ubuntu:22.04, ubuntu:24.04 ]
1616 runs-on : ubuntu-latest
1717 container :
1818 image : ${{ matrix.distro }}
@@ -24,50 +24,68 @@ jobs:
2424 - name : Install Dependencies
2525 run : |
2626 apt-get update -qq
27- # Install all potential dependencies your script needs to avoid failures
28- apt-get install -y -qq curl wget openssh-server openssh-client sudo ufw gpg chrony
27+ # Install all potential script dependencies to ensure a clean run
28+ apt-get install -y -qq curl wget openssh-server openssh-client sudo ufw gpg chrony procps
2929
3030 - name : Make Script Executable
3131 run : chmod +x ./setup_harden_debian_ubuntu.sh
3232
3333 - name : Run Hardening Script Non-Interactively
3434 run : |
35- # Use a "here document" to pipe answers to all interactive prompts
35+ # Use a "here document" to pipe a precise sequence of answers to all interactive prompts
3636 # This simulates a user providing input for a fully automated test.
3737 sudo ./setup_harden_debian_ubuntu.sh --quiet <<'EOF'
3838 testadmin
3939 testhost
4040 My Test Server
4141 2222
4242 y
43+ n
44+
45+
4346 n
4447 y
4548 y
4649 n
4750 n
4851 n
4952 y
53+ y
54+ n
55+ y
5056 2G
5157 n
5258 n
5359 EOF
54- # Explanation of the inputs above:
60+ # --- Explanation of the inputs above ---
5561 # testadmin -> New admin username
5662 # testhost -> Server hostname
5763 # My Test Server -> Pretty hostname
5864 # 2222 -> Custom SSH port
59- # y -> Confirm configuration
65+ # y -> Confirm main configuration
6066 # n -> Skip interactive locale config
61- # n -> Don't add another SSH key (assumes ssh-copy-id step is skipped in CI)
62- # y -> Confirm SSH connection was "tested"
67+ # "" (empty line) -> New password (skips)
68+ # "" (empty line) -> Retype password (skips)
69+ # n -> Add SSH key(s) from local machine? (No, triggers auto-generation)
70+ # y -> Confirm local key login was "successful" (to proceed)
71+ # y -> Confirm new SSH port connection was "successful" (to proceed)
6372 # n -> Don't allow HTTP
6473 # n -> Don't allow HTTPS
6574 # n -> Don't add custom UFW ports
6675 # y -> Enable auto-updates
76+ # y -> Install Docker?
77+ # n -> Install Tailscale?
78+ # y -> Configure swap?
6779 # 2G -> Swap size
6880 # n -> Don't customize swap settings
6981 # n -> Don't reboot at the end
7082
83+ - name : Display Log on Failure
84+ if : failure()
85+ run : |
86+ echo "::error::Script failed. Displaying last 50 lines of log:"
87+ tail -n 50 /var/log/setup_harden*.log
88+
7189 - name : Verify Final SSH Configuration
7290 run : sudo sshd -t
7391
0 commit comments