Skip to content

Instantly share code, notes, and snippets.

@NQevxvEtg
NQevxvEtg / bulk-ssh-copy.sh
Last active July 30, 2025 17:04
sshcopyid
#!/usr/bin/env expect -f
# Prompt for SSH password once
stty -echo
send_user "Enter SSH password: "
expect_user -re "(.*)\n"
stty echo
send_user "\n"
set ssh_password $expect_out(1,string)

How to Add Multiple Users in a Single Polkit Rule

Create a new file in the /etc/polkit-1/rules.d/ directory, for example, 50-pcsc-multiple-users.rules.

Use the following JavaScript code, replacing "user1", "user2", and "user3" with the actual usernames of the individuals who need access. You can add as many users as you need.

polkit.addRule(function(action, subject) {
  if (action.id == "org.debian.pcsc-lite.access_pcsc" && (subject.user == "user1" || subject.user == "user2" || subject.user == "user3")) {
 return polkit.Result.YES;
# 1. Create LVM Map (Major:Minor -> vgname/lvname)
LVM_MAP=$(sudo lvs --noheadings -o lv_kernel_major,lv_kernel_minor,vg_name,lv_name --separator : | tr -d ' ')
# 2. Iterate using -P (Pairs) to handle empty columns safely.
lsblk -P -n -o NAME,TYPE,FSTYPE,MAJ:MIN,MOUNTPOINT | sed 's/MAJ:MIN/MAJMIN/g' | while read -r line; do
# Load variables safely
eval "$line"
# EXCLUSION: Skip Boot partitions
#!/bin/bash
# --- INITIALIZATION ---
# Hide cursor for a clean look
tput civis
# Ensure cursor returns on exit
trap "tput cnorm; echo -e '\nExiting...'; exit" SIGINT
# --- DATA GATHERING ---
get_stats() {
#!/bin/bash
umask 0022
MIRROR_DIR="/var/www/html/yum"
REPOS=(
# Oracle Linux 9 (and EPEL 9 for RHEL 9)
"ol9_baseos_latest"
"ol9_appstream"
#!/bin/bash
#
# networkmonitor.sh - Per-process network bandwidth monitor (nethogs alternative)
#
# Samples 'ss -tupni' byte counters (bytes_acked / bytes_received) per connection,
# maps them to PIDs, and computes upload/download rates.
#
# Usage: ./networkmonitor.sh [interval_seconds]
# Run as root (sudo) for full visibility of all processes.
#!/bin/bash
# Check if a file path was provided
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/your/logfile.log"
exit 1
fi
FILE=$1
#!/usr/bin/env bash
# Exit immediately if any command fails
set -e
# --- CONFIGURATION ---
FAILED_LIST="failed_servers.txt"
ENV_DIR="./environments"
OUTPUT_FILE="classified_failed_servers.txt"
TEMP_FILE="matched_raw.tmp"
#!/bin/bash
# --- CONFIGURATION ---
FORWARD_ZONES=("example.com" "internal.lan")
# ---------------------
if ! klist -s; then
echo "❌ Error: No valid Kerberos ticket found. Please run 'kinit admin' first."
exit 1
fi
#!/usr/bin/env python3
"""
Bulk-add PTR records to FreeIPA DNS, driven by a CSV file.
CSV format (no header):
fqdn,ip
Example:
host1.example.com,192.168.1.50
host2.example.com,10.0.0.75