Skip to content

Instantly share code, notes, and snippets.

View ElijahLynn's full-sized avatar
😎
All Your DevOps Belong To Us

Elijah Lynn ElijahLynn

😎
All Your DevOps Belong To Us
View GitHub Profile
@ElijahLynn
ElijahLynn / gcp-project-metadata-ssh-key-finder-parallel.sh
Created July 19, 2024 20:55
Script to search the metadata of all GCP projects for an SSH public key
#!/bin/bash
# Define color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check if an argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <public-ssh-key>"
@ElijahLynn
ElijahLynn / monitor-number-tcp-connection-states.sh
Last active January 20, 2024 22:49
Monitor the number of all TCP connection states
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
# Every 1.0s: netstat -an | awk '/^tcp/ { ++S[$NF] } END { for(a in S) print a, S[a] }'
# LISTEN 7
# FIN_WAIT_2 1
# CLOSE_WAIT 1
# CLOSED 33
# TIME_WAIT 1
# ESTABLISHED 63
@ElijahLynn
ElijahLynn / gist:d76d31eca63d984efa424b08dee2905b
Last active October 8, 2024 20:15
Remote tcpdump stream to wireshark

Archived from https://twitter.com/ElijahLynn/status/1144399526452588545

Just had to debug yum returning a 503 on a server deep in a private network, but curl worked fine. Was able to use tshark and pipe it to my local wireshark and re-assemble the HTTP request that finally told me it was blocked by the internet gateway and who to email!

Here is the command that piped in realtime the tshark dump to my local wireshark GUI. Don't worry about the CLI filter because we can just use display filters to get what we want. Then find a GET packet, right click and "Follow" > TCP||HTTP Stream

ssh user@host 'sudo /usr/sbin/tshark -i eth0 -f "port !22" -w -' | wireshark -k -i -

Ahh, the only reason this worked was because the URL was http. Need to figure out how to do https now.

@ElijahLynn
ElijahLynn / output.txt
Created October 20, 2023 18:34
Show all TCP connections and states (1 liner)
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
@ElijahLynn
ElijahLynn / gist:14a1470d3a344b16489b6b9678e28956
Last active January 20, 2023 22:00
drud/ddev/issue/4570
Running bash [-c /tmp/test_ddev.sh]
======= Existing project config =========
These config files were loaded for project va-gov-cms: [/home/elijah/Projects/va.gov/va.gov-cms/.ddev/config.yaml]
name: va-gov-cms
type: drupal9
docroot: docroot
php_version: 8.1
webserver_type: nginx-fpm
webimage: drud/ddev-webserver:v1.21.4
## https://stackoverflow.com/questions/34658836/docker-is-in-volume-in-use-but-there-arent-any-docker-containers?answertab=trending#comment128478332_42116347
function docker-remove-containers --description "Remove all docker containers"
docker stop (docker ps --all --quiet)
docker rm (docker ps --all --quiet)
end
funcsave docker-remove-containers
### Keybase proof
I hereby claim:
* I am elijahlynn on github.
* I am elijahlynn (https://keybase.io/elijahlynn) on keybase.
* I have a public key ASBeMFqKeluy3X7oeF-D-Zh05Q3rxHtuggP7XY2ICXlgoQo
To claim this, I am signing this object:
@ElijahLynn
ElijahLynn / simplehttp.service
Last active May 7, 2019 05:25 — forked from funzoneq/simplehttp.service
A systemd file for a Python SimpleHTTPServer
# Upstream https://gist.github.com/ElijahLynn/ce1a103a6caa7dbd11f7facb3c943f8f
[Unit]
Description=Job that runs the Python SimpleHTTPServer daemon
Documentation=man:SimpleHTTPServer(1)
[Service]
Type=simple
WorkingDirectory=/tmp/backups
ExecStartPre=-/usr/bin/mkdir /tmp/backups
ExecStart=/usr/bin/python -m SimpleHTTPServer 80 &
@ElijahLynn
ElijahLynn / guake_fullscreen_toggle.py
Last active June 7, 2022 23:15
Script to toggle fullscreen for Guake 0.8.x
#!/usr/bin/env python2
# -*- coding: utf-8; -*-
# Depends on https://github.com/Guake/guake/pull/1446
import dbus
try:
bus = dbus.SessionBus()
remote_object = bus.get_object('org.guake.RemoteControl', '/org/guake/RemoteControl')
remote_object.fullscreen_toggle()
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {