# Configuration
CONFIG_FILE="/etc/ssh/sshd_config"
PQC_KEX="KexAlgorithms +sntrup761x25519-sha512@openssh.com"

# 1. Check if the line already exists to avoid duplicates
if grep -Fxq "$PQC_KEX" "$CONFIG_FILE"; then
    log "The Post-Quantum Kex is already configured in $CONFIG_FILE."
else
    log "Adding Post-Quantum Kex to the top of $CONFIG_FILE..."
    # 2. Backup the original file
    cp "$CONFIG_FILE" "${CONFIG_FILE}.bak_pq"
    # 3. Use 'sed' to insert the line at the very beginning (line 1)
    # The 'i' command in sed inserts text before the specified line
    sed -i "1i $PQC_KEX" "$CONFIG_FILE"
fi
