Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
mttjohnson / gist:d648b2285d5d88cbe5742b373618dcbd
Last active May 12, 2026 13:39
Troubleshooting Yum Repos
# https://unix.stackexchange.com/questions/222750/sudo-yum-repolist-show-repo-not-in-etc-yum-repo-d
yum repolist
yum repoinfo ius
# Repos are either defined via .repo files in /etc/yum.repos.d or via plugins, which are usually defined via files in /etc/yum/pluginconf.d
ls -la /etc/yum.repos.d
ls -la /etc/yum/pluginconf.d
# If you run yum repolist --noplugins does your repo in question still show up?
@mttjohnson
mttjohnson / system_performance_monitoring.sh
Last active March 27, 2026 06:36
Linux System Performance Monitoring
# Poll for various system stats for monitoring system
# Just copy and paste the commands into a bash prompt
# Use Ctrl-C to exit the polling
# Simple Example (CPU/Load/Memory)
# Settings
INTERVAL_DURATION="5" # seconds to average across
TIME_PAD=' '
@mttjohnson
mttjohnson / convert_openssl_to_ssh_key.sh
Last active March 27, 2026 06:36
convert openssl key to ssh key format
# convert openssl to ssh key
PUB_KEY=$(cat <<KEY_DETAILS
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "my_comment_or_username_here"
AAAAB3NzaC1yc2EAAAADAQABAAABAQC14HPz8nY48W4gxlxDxXy6RDEO2msaOiO38SzoWr
CT+3dz1TmT1nHb/UCeQ3iPFV+th9Rnq2Zrh2B4/kGQTyEotsa+1lnG8/3rL8QZZ7VVw0Ee
3bys8O0+jRUeTH1wljGpL7KzlCrfSCRqMXqTQm7Lg+WM0FUqSJX9iuzue45XtHonQnKdAX
bsQoMBrCsbwv1qfiTHW1LYJX1fAuoHeVUDQKWfABLsSiixkEnATut36w/G1AW0RgTN2K+4
pJ3NIPWdsauzcVl+kLnFrRbGMUtZrOCAFv2sC7/6B5L5oRSEoYZKvVnIUOvhr6zY1BagX0
igFD6DEmLVKsXOZ8cLuUb3
@mttjohnson
mttjohnson / postfix_sasl.sh
Last active March 27, 2026 06:36
Postfix SASL Authentication Setup and Testing
# Checking for Postfix Configs
which sendmail
ls -la /usr/sbin/sendmail
ls -la /etc/alternatives/mta
ls -la /usr/sbin/sendmail.postfix
cat /etc/postfix/main.cf | grep relayhost
# Install any necessary dependencies for sasl authentication (debian)
apt-get install libsasl2-2 libsasl2-modules
@mttjohnson
mttjohnson / rsync_examples.sh
Last active March 27, 2026 06:36
rsync examples (two remotes)
# rsync with sudo
rsync -av \
--rsync-path="sudo -u www-data rsync" \
-e 'ssh -o StrictHostKeyChecking=no' \
path_to_local_data/ user_name@example.com:/var/www/
# If you wanted to build an exclusion list from a list of files in a directory
# This was useful when trying to sync a list of files but exclude a list of default installed
# so that the destination only contained the differences of what was added that wasn't a part
@mttjohnson
mttjohnson / web_dev_intro.md
Last active March 27, 2026 06:36
Web Development Intro
@mttjohnson
mttjohnson / validate_ssh_key.sh
Last active March 27, 2026 06:36
Validating ssh keys
# When you SSH into a server for the first time it prompts you if you trust the remote server's host key
# To validate that they key you received is the same as the server you just logged into you can check
# the fingerprint of the host key on the remote server itself.
# Output fingerprint of system's host key
ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
# You can fingerprint both the private and public key from a file
# They should both produce the same fingerprint value.
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
@mttjohnson
mttjohnson / check_postgres_ssl_cert.sh
Created April 23, 2021 15:44
Check Postgres SSL Cert
# Heroku Postgres spins up instances that could be using self-signed certificates
# You can view the details of a Postgres certificate to validate it
openssl version
# version 1.1.1+ supports postgres client connections
# RHEL 8 / CentOS 8 should have a new enough version of openssl
# macOS 11 uses LibreSSL and does not have support for this
POSTGRES_HOST="my_postgres_db.lan"
POSTGRES_PORT="5432"
@mttjohnson
mttjohnson / remote_ssh_commands_via_sudo.sh
Created April 6, 2018 21:29
Running commands via sudo on remove SSH connection
# Run a command on a remote server using sudo to execute commands as root
ssh -t ssh_user@ssh_host \
"
sudo -u root -- sh -c \"
whoami;
cat ~/.ssh/authorized_keys
\"
"
# The same command without the sudo wrapper
@mttjohnson
mttjohnson / http_monitor.sh
Created November 20, 2025 06:41
http continuous ping script for monitoring an http service
#!/bin/bash
# Simple HTTP Monitor Script
URL="$1"
INTERVAL="${2:-5}"
if [ -z "$URL" ]; then
echo "Usage: $0 <URL> [interval_seconds]"
echo "Example: $0 https://google.com 2"
exit 1