Skip to content

Instantly share code, notes, and snippets.

View yash1th's full-sized avatar
💭
I may be slow to respond.

yash yash1th

💭
I may be slow to respond.
View GitHub Profile
@yash1th
yash1th / self-signed-certificate-with-custom-ca.md
Created October 14, 2024 12:14 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@yash1th
yash1th / bash_strict_mode.md
Created November 16, 2023 02:36 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@yash1th
yash1th / macOS Internals.md
Created May 7, 2023 18:55 — forked from kconner/macOS Internals.md
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@yash1th
yash1th / awssessiontoken
Created September 6, 2022 12:26 — forked from tfentonz/awssessiontoken
Set environment variables to use MFA token with AWS CLI
#!/bin/bash
#
# https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/
#
# Usage: source ~/bin/awssessiontoken
# arn:aws:iam::12345689012:mfa/ExampleMFADevice
mfa_arn=$(aws iam list-mfa-devices --query 'MFADevices[].SerialNumber' --output text)
echo "MFA ARN: $mfa_arn"
echo -n "Enter MFA Code: "
@yash1th
yash1th / brew.md
Created September 4, 2022 14:57 — forked from pudquick/brew.md
Lightly "sandboxed" homebrew on macOS

brew is a bad neighbor

This isn't a guide about locking down homebrew so that it can't touch the rest of your system security-wise.

This guide doesn't fix the inherent security issues of a package management system that will literally yell at you if you try to do something about "huh, maybe it's not great my executables are writeable by my account without requiring authorization first".

But it absolutely is a guide about shoving it into its own little corner so that you can take it or leave it as you see fit, instead of just letting the project do what it likes like completely taking over permissions and ownership of a directory that might be in use by other software on your Mac and stomping all over their contents.

By following this guide you will:

  • Never have to run sudo to forcefully change permissions of some directory to be owned by your account
@yash1th
yash1th / get_token.md
Created August 2, 2022 14:56 — forked from brianredbeard/get_token.md
aws, sts, and bash

About

AWS provides a mechanism for temporarily assuming another role within their API system. While it is not a technically hard process it can be convoluted and hard to understand. This document aims to both make it easier to follow along with as well as give an in depth explanation of some of the underpinnings of the Bourne Again Shell (aka BASH) which can make this easier to utilize on a day to day basis.

Explanation

Below is an overexplained version of the following process:

  1. Using credentials stored in ~/.aws/credentials as a "profile" which are then understood by the AWS command line tools
  2. Using those AWS credentials, temporarily assume a role using the AWS Security Token Service (STS) to get temporary
@yash1th
yash1th / sts2env
Created August 2, 2022 14:37 — forked from russellballestrini/sts2env
Configure your shell with temporary AWS environment variables from
#!/usr/bin/env python
"""
How to use:
eval $(eval "aws sts assume-role --role-arn arn:aws:iam::0123456789:role/the-role-name --role-session-name my-aws-prod | ./sts2env")
Then run `env` and you should see the environment vars in your shell.
"""
@yash1th
yash1th / letsencrypt.py
Created April 26, 2022 16:07 — forked from gpjt/letsencrypt.py
Sample acme code to get a certificate from Let's Encrypt
# There's a lack of sample code for acme/Let's Encrypt out there, and
# this is an attempt to at least slightly remedy that. It's the result
# of my first day's hacking on this stuff, so almost certainly contains
# errors and oversights.
#
# It's not designed to be specifically useful if what you want is
# just a cert -- certbot or dehydrated are better for that. It is sample
# code for people who are building automated systems to deal with large
# numbers of Let's Encrypt certificates to play with.
#