diff --git a/linux/running-services.sh b/linux/running-services.sh new file mode 100644 index 0000000..90a6d4d --- /dev/null +++ b/linux/running-services.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Description: Basic Pretty Systemctl Services Status Script +# Author: Victor Bishop (Heretic) | https://github.com/Heretic312/devsecops-wrappers +# Date: 12/12/2025 + +# List all systemctl services and color them based on their status +systemctl list-unit-files | awk ' +/enabled/ {print "\033[32m" $0 "\033[0m"; next} # Green for enabled +/disabled/ {print "\033[31m" $0 "\033[0m"; next} # Red for disabled +/static/ {print "\033[34m" $0 "\033[0m"; next} # Blue for static +/alias/ {print "\033[35m" $0 "\033[0m"; next} # Purple for alias +{print $0} # Default output for other lines +' + +# List all systemctl services and color the whole line for enabled services +#systemctl list-unit-files | awk '/enabled/ {print "\033[32m" $0 "\033[0m"; next} {print $0}' + + +# List all running systemctl services and highlight enabled ones with color +#systemctl list-unit-files | grep --color=auto 'enabled' diff --git a/linux/ssh_harden.sh b/linux/ssh_harden.sh new file mode 100644 index 0000000..1ca6f67 --- /dev/null +++ b/linux/ssh_harden.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +# Script Name: ssh_harden.sh +# Description: SSH hardening script for Debian 12 (Bookworm) based on https://www.sshaudit.com/hardening_guides.html#debian_12 +# Author: Victor Bishop | https://github.com/Heretic312/devsecops-wrappers +# Version: 1.1 +# Usage: sudo ./ssh_harden.sh +# Notes: Adjust SSH_PORT as needed if not using port 22 + +SSH_PORT=22 # Change this to your SSH port if not using 22 + +# Ensure script is run as root +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." >&2 + exit 1 +fi + +# Function to regenerate SSH host keys +regenerate_ssh_keys() { + read -p "WARNING: This will DELETE and REGENERATE SSH host keys. Continue? (y/n): " confirm + [[ $confirm != [yY] ]] && echo "Cancelled." && return + + echo "Regenerating SSH host keys..." + rm -f /etc/ssh/ssh_host_* + ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N "" + ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" + + # Clean existing HostKey lines to prevent duplication + sed -i '/^HostKey \/etc\/ssh\/ssh_host_/d' /etc/ssh/sshd_config + echo -e "HostKey /etc/ssh/ssh_host_ed25519_key\nHostKey /etc/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config + + awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe + mv /etc/ssh/moduli.safe /etc/ssh/moduli + + echo "SSH host keys regenerated successfully." +} + +# Function to apply SSH hardening configuration +apply_ssh_hardening() { + echo "Applying SSH hardening configuration..." + cat > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf <