CIS Controls Ubuntu 22.04 Scripts

Hello!
This is my first post, and surprise it is tech support.

I am trying to get my servers to comply with the CIS Ubuntu Linux 22.04 LTS Benchmark.
The problem I have is that copying all of the scripts manually from the PDF will take extremly long and most of the time the formatting screws it up.
So… does anyone have the scripts in a proper format? I’m trying to avoid to buy Ubuntu Pro.

Thanks in advance :slight_smile:

I haven’t got what you request, but you could run pdftotext on the PDF, run a script (say, awk) to find shebangs (line beginning with #!) and write out the scripts to separate files. Like copy/paste the formatting is lost, but re-indenting (say, with vim) could be automated; I tried one script and it the result was usable.

Could you show me? I have done very little shell scripting…

I’ll need to scrape a little time on my desktop at home (which I haven’t got to since Friday).

Here’s a 4 line gnu awk script (that assumes only one script on a page):

/^Page / { curpg = $2 + 1}
/^#!\/usr\/bin\/env bash/ { output = "cis" curpg ".sh" }
/^#!\/usr\/bin\/env bash/, /^$/ { if (/^Page/) {getline;next}
                                  print > output }

save it in a file cis.awk, and assuming you have pdftotext and gawk installed, you’d run

pdftotext -nopgbrk CIS_Ubuntu_Linux_22.04_LTS_Benchmark_v1.0.0.pdf
awk -f cis.awk CIS_Ubuntu_Linux_22.04_LTS_Benchmark_v1.0.0.txt

and you get 79 cisnnn.sh files. I didn’t try to run any of them. In vim you can use =G to reindent them, but they still look awful.

Thank you!
How they look is not that important, but thanks to some of what should be one line that are devided in two, at least some of the scripts are broken. But that can be fixed very easily.
So long that I don’t need to copy+paste from the PDF, I am happy :slight_smile: