Skip to content

Instantly share code, notes, and snippets.

@Hefeweizen
Hefeweizen / encrypt.txt
Created January 18, 2024 23:34 — forked from phrfpeixoto/encrypt.txt
Using SSH public key to encrypt a file or string
# Recently I had to send a password to someone over Skype. Since that's obviously not a good idea, I asked for
# the person's public SSH RSA key, and used it to encrypt the password itself.
# Convert the public key into PEM format
ssh-keygen -f path/to/id_rsa.pub -e -m pem > ~/id_rsa.pub.pem
# Using the public pem file to encrypt a string
echo "sometext" | openssl rsautl -encrypt -pubin -inkey ~/id_rsa.pub.pem > ~/encrypted.txt
@Hefeweizen
Hefeweizen / prom-outlier.md
Created October 22, 2021 21:59
Prometheus Outlier Detection

Outlier Detection

We sometimes experience a node(s) running hot. Determining what to do is conditional on the rest of the cluster. If it’s one node out of 50 that’s running hot, we can chalk it up too “bad node” and kill it. However, if it’s >50% of the nodes running hot, we should seek to understand what’s happening within the service. To that end, I wanted to create an alert on outlier nodes.

Let’s start with cumulative idle on a host:

sum without(cpu, job) (irate(node_cpu{host=~"prod-foo.*",mode="idle"}[3m]))

Idle is the measure of unused CPU, so it’s a shortcut for matching mode !~ "idle". Should we care, we’d want to subtract this from 1 to get the consumed CPU. Also of note, we accumulating idle from all CPUs on the host, and not averaging per cpu.

Now, let’s get the average idle for the cluster:

@Hefeweizen
Hefeweizen / .sshconfig
Created December 18, 2020 23:15
My company uses Github for repo storage. I generally check out work repos to ~/Workspace. Other stuff, like my ~/dotfiles are going to other directories. So, here, I use my company wide id_ed25519 key for ssh access to github if I'm in '*/Workspace'. Otherwise, I use credentials scoped to my personal Github account.
Host *
PermitLocalCommand yes
StrictHostKeyChecking ask
Host github.com
HostName github.com
User git
IdentitiesOnly yes
Match Host github.com exec "pwd | grep '/Workspace' > /dev/null"
@Hefeweizen
Hefeweizen / gist:a4c6ffb6e06a87ac338ffce3d13512f1
Last active May 31, 2021 17:47
Multiple SSH Keys for Different Github Accounts on the Same Computer

Multiple SSH Keys for Different Github Accounts on the Same Computer

This is a good article for how to get multiple accounts, with differing ssh keys, to work with github: https://medium.com/@xiaolishen/use-multiple-ssh-keys-for-different-github-accounts-on-the-same-computer-7d7103ca8693

I started with this, but this scheme means I can't just cut-paste the repo link from browser to command line; I'd have to rewrite the host every time I want to use the second key. Example:

# This will always pick up my main ssh key
git clone git@github.com:Hefeweizen/junk.git