Skip to content

Instantly share code, notes, and snippets.

View nightspotlight's full-sized avatar

Roman Eremeev nightspotlight

  • Poland
  • 06:29 (UTC +01:00)
View GitHub Profile
@nightspotlight
nightspotlight / aws_accounts.csv
Created December 17, 2025 15:56
Sedai script to update group with AWS accounts
account_id account_name
012345678901 testacc1
123456789012 testacc2
@nightspotlight
nightspotlight / aws_get_account_ou_csv.sh
Created December 16, 2025 14:59
Get account name and OU from AWS account id
#!/usr/bin/env bash
export AWS_PAGER=""
declare -a acc_ids=(
012345678901
123456789012
)
declare -a acc_names
declare -a acc_ous
@nightspotlight
nightspotlight / ssm-start-session-function.sh
Created October 31, 2025 18:35
A shell function to use `aws ssm start-session` with temporary static IAM user credentials
#!/usr/bin/env bash
function ssm-start-session() (
local target="${1?Usage: ssm-start-session <instance-id>}"
local timestamp username policy_arn access_key_json
timestamp=$(date +%s)
username="ssm-session-temp-$timestamp"
policy_arn='arn:aws:iam::aws:policy/AdministratorAccess'
declare -x \
@nightspotlight
nightspotlight / LUKS_and_TPM2_with_Fedora.md
Last active January 17, 2023 09:07 — forked from jdoss/LUKS_and_TPM2_with_Fedora.md
Decrypt LUKS volumes with a TPM on Fedora 35+

Decrypt LUKS volumes with a TPM on Fedora 35+

This guide allows you to use the TPM on your computer to decrypt your LUKS encrypted volumes. If you are worried about a cold boot attack on your hardware please DO NOT use this guide with your root volume!

Preflight Checks

Verify that you have a TPM in your computer:

# systemd-cryptenroll --tpm2-device=list
PATH DEVICE DRIVER
@nightspotlight
nightspotlight / gcloud-activate.sh
Created July 30, 2020 18:36
Switch your Google Cloud service accounts on the command line
# put this in your ~/.profile, then reload your shell
function gcloud-activate() {
local action="$1"
local account=""
local credentials=""
case "${action}" in
alpha)
account="[email protected]"
credentials="${HOME}/.config/gcloud/my-project-alpha.json"
@nightspotlight
nightspotlight / nexus-rpm-multiupload.sh
Created July 6, 2020 09:33
Upload multiple RPM files to a Maven repository in Sonatype Nexus Repository Manager 2
#!/usr/bin/env bash
for f in *.rpm; do
rpminfo="$(rpm -qp --queryformat "%{NAME} %{VERSION}-%{RELEASE} %{ARCH}\n" "${f}" 2>/dev/null)"
group="org.centos-7.rpm"
artifact="$(echo "${rpminfo}" | cut -d ' ' -f 1)"
version="$(echo "${rpminfo}" | cut -d ' ' -f 2)"
classifier="$(echo "${rpminfo}" | cut -d ' ' -f 3)"
curl -fsSL \
-u nexus_user:nexus_password \
@nightspotlight
nightspotlight / ipv6.sh
Last active October 27, 2019 21:03
Enable IPv6 inside a FreeBSD jail (FreeNAS-11.2-U3)
#!/bin/sh
/sbin/ifconfig epair0b inet6 auto_linklocal accept_rtadv autoconf
/sbin/rtsol epair0b
# sysrc rtsold_enable=YES
# service rtsold start
@nightspotlight
nightspotlight / mdns.sh
Last active April 22, 2019 12:54
Enable mdns inside a FreeBSD jail (FreeNAS-11.2-U3)
# # cat /usr/local/etc/pkg/repos/FreeBSD.conf
# FreeBSD: { enabled: no }
rm -f /usr/local/etc/pkg/repos/FreeBSD.conf
pkg update -f
pkg install --yes openmdns
sysrc mdnsd_enable=yes
sysrc mdnsd_flags=epair0b
service mdnsd start
@nightspotlight
nightspotlight / datetime.groovy
Last active June 22, 2018 20:41
A Groovy script to display given time in different timezones
#!/usr/bin/env groovy
//TimeZone.setDefault(TimeZone.getTimeZone('Europe/Warsaw'))
if (args.size() == 0 || !args.find { it ==~ /^\d{2}\.\d{2}\.\d{4}\ \d{2}\:\d{2}$/ }) {
String thisScript = new File(this.getClass().protectionDomain.codeSource.location.path).getName()
System.err.println "Error parsing command line arguments!"
System.err.println "Usage: ${thisScript} <dateTime>"
System.err.println "Accepted dateTime format is dd.mm.yyyy hh:mm"
System.err.println "Example: ${thisScript} '25.05.2018 05:00'"
@nightspotlight
nightspotlight / windows10-ipv6-stateful.bat
Created August 20, 2017 19:06
Windows script to disable random IPv6 address and IPv6 privacy extensions
netsh interface ipv6 set privacy state=disabled store=active
netsh interface ipv6 set privacy state=disabled store=persistent
netsh interface ipv6 set global randomizeidentifiers=disabled store=active
netsh interface ipv6 set global randomizeidentifiers=disabled store=persistent
netsh interface ipv6 set interface 15 routerdiscovery=disabled
netsh interface ipv6 set interface 15 managedaddress=enabled
netsh interface ipv6 set interface 15 otherstateful=enabled