Skip to content

Instantly share code, notes, and snippets.

@tdonaworth
tdonaworth / credentials.Jenkinsfile
Created April 25, 2022 20:37
Multiple ways to dump credentials from Jenkins
pipeline {
agent any
stages {
stage('usernamePassword') {
steps {
script {
withCredentials([
usernamePassword(credentialsId: 'gitlab',
usernameVariable: 'username',
@tdonaworth
tdonaworth / copy_key_to_server.sh
Created February 10, 2022 13:29
Copy SSH Public Key to a system.
#!/usr/bin/env bash
h="server01"
# Your PUBLIC key
key="~/.ssh/my_id_rsa.pub"
cat ${key} | ssh ${h} 'umask 077; mkdir -p .ssh; cat >> .ssh/authorized_keys && echo "Key copied!"'
@tdonaworth
tdonaworth / S3_encrypt_all_buckets.sh
Created February 10, 2022 13:24
Encrypts all S3 Buckets with SSE-AES256 encryption
aws s3api list-buckets \
--output text \
--query "Buckets[*].[Name]" \
| \
xargs -t -I {} \
aws s3api put-bucket-encryption \
--bucket {} \
--server-side-encryption-configuration \
'{"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]}'
@tdonaworth
tdonaworth / get_s3_encryption_status.sh
Created February 10, 2022 13:23
Lists out the S3 Server-Side-Encryption (SSE) status and Algorithm
#!/bin/bash
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
echo '----------------------------------------------------------'
echo '| Bucket | SSE Algorithm |'
echo '----------------------------------------------------------'
while read -r bucket
@tdonaworth
tdonaworth / delete_bucket.sh
Created February 10, 2022 13:22
Given a bucket name, will delete all objects, versions and the bucket it self recursively.
#!/bin/bash
bucket=$1
set -e
versioning=$(aws s3api get-bucket-versioning --bucket $bucket | jq '.Status')
#echo $versioning
if [ "$versioning" != '"Enabled"' ];
then
@tdonaworth
tdonaworth / S3_block_public.sh
Created February 10, 2022 13:22
Enable 'Public Access Block' for all S3 buckets
#!/bin/bash
set -e
aws s3api list-buckets \
--output text \
--query "Buckets[*].[Name]" \
| \
xargs -t -I {} \
aws s3api put-public-access-block \
--bucket {} \

Keybase proof

I hereby claim:

  • I am tdonaworth on github.
  • I am tdonaworth (https://keybase.io/tdonaworth) on keybase.
  • I have a public key ASAklwoDlXOEycB0_UNtbU4kvBzidTyRt___30Su2i-ROwo

To claim this, I am signing this object: