Skip to content

Instantly share code, notes, and snippets.

View ollytheninja's full-sized avatar

Olly E ollytheninja

View GitHub Profile
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up --advertise-tags=tag:server --ssh --accept-routes
sudo tailscale up --advertise-routes=10.1.0.0/24 --advertise-exit-node --advertise-tags=tag:server,tag:demo --ssh --accept-routes
@ollytheninja
ollytheninja / find_duplicate_tags.py
Created February 22, 2022 22:39
Find duplicate yor_trace tags
from pathlib import Path
globs = Path(".").glob("*/*.tf")
traces = []
duplicates = []
for glob in globs:
with glob.open() as f:
for line in f:
@ollytheninja
ollytheninja / remove_tag.sh
Created February 3, 2022 20:12
Remove specific lines from a bunch of files
# When you need to remove a tag from a bunch of Terraform
find . -type f -name "*.tf" -exec sed -i -e '/^.*git_commit.*$/d' {} \;
# Probably want to delete the "-e" files that were created for all files that didn't have the tag in them
find . -type f -name "*.tf-e" -delete
import boto3
import botocore
def validate_key(id, secret):
sts = boto3.client('sts', aws_access_key_id=id, aws_secret_access_key=secret)
try:
identity = sts.get_caller_identity()
print('Identity ARN: ' + identity['Arn'])
except botocore.exceptions.ClientError as e:
@ollytheninja
ollytheninja / invalidate_aws_key.py
Created April 20, 2021 03:14
Invalidate AWS access keys
import boto3
from botocore.exceptions import ClientError
def invalidate_key(id, secret):
iam = boto3.client('iam', aws_access_key_id=id, aws_secret_access_key=secret)
try:
iam.update_access_key(
AccessKeyId=id,
@ollytheninja
ollytheninja / anchore.sh
Last active September 25, 2020 03:27
How to get Anchore Engine up and running with Helm 3 and Kubernetes quick and easy
# Requires kubernetes and Helm v3 installed
# Install using Helm chart
helm repo add anchore https://charts.anchore.io
helm install anchore-1 anchore/anchore-engine
# Connect to cli
kubectl exec service/anchore-1-anchore-engine-api -it /bin/bash
# iptables dance, probably needs reviewing
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i eth0 -j ACCEPT
iptables -P INPUT DROP
iptables -A FORWARD -i wlan0 -o wlan0 -j REJECT
# Show ip tables
iptables -L -v -n
iptables -S
@ollytheninja
ollytheninja / pair.py
Created December 2, 2019 04:16
silly little script for pairing things together in a CSV, used to pair a barcode and RFID card serial together
import os
output_file = "card_pairs.csv"
magic_number = 4
if output_file not in os.listdir('.'):
with open(output_file, "w") as f:
f.write("id_number,card_serial\n")
while 1:
@ollytheninja
ollytheninja / install_aws2.sh
Created December 1, 2019 22:42
Install the preview version of AWS CLI V2 from source
mkvirtualenv aws2
workon aws2
pip install -e git://github.com/boto/botocore.git@v2#egg=botocore
pip install -e git://github.com/aws/aws-cli.git@v2#egg=awscli
alias aws2='python -m awscli'
@ollytheninja
ollytheninja / keybase.md
Last active May 1, 2022 22:20
keybase.md

Keybase proof

I hereby claim:

  • I am ollytheninja on github.
  • I am oliverewert (https://keybase.io/oliverewert) on keybase.
  • I have a public key ASCpu8NNJTOI8ZsBp5Wa7cUFtBPZwN9HEBf9Kq6P0aB_8Qo

To claim this, I am signing this object: