Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Geiger blurayne

View GitHub Profile
@blurayne
blurayne / ui-widget-select.sh
Last active Nov 3, 2020
Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
View ui-widget-select.sh
#!/bin/bash
##
# Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#
# Author: Markus Geiger <mg@evolution515.net>
# Last revised 2019-09-11
#
# ATTENTION! TO BE REFACTORED! FIRST DRAFT!
#
@blurayne
blurayne / 1-README.md
Last active Sep 11, 2019
Variable types in BASH (typeof implementation)
View 1-README.md

Myth about associative arrays in BASH

To be clear: It's possible to pass associative arrays in BASH.

TL;DR you probably didn't RTFM so please njoy following session!

CODE

Pass an associative array the correct-BASH way

@blurayne
blurayne / ssh-copy-key
Last active Sep 11, 2019
ssh-copy-key
View ssh-copy-key
#!/bin/bash
# vim:tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab
# vim:syntax=sh
##
# ssh-copy-key - a better ssh-copy-id
#
# - have a different identify file to copy to remote host (and just one!)
# - (infrastructure where you don't own private key but wanna role out your private key –like it should be done ;)
# - automatically generates public key if not yet given
View snowflake-reconnaisance.md

Snowflake Reconnaissance

About

This page will assist you in retrieving important information from so called Snowflake Server which exist in your infrastructure unversioned and with unknown status. The basic idea is that system files in a modern system are under packages control, which enables us to do following:

  • verify files and look for changed and missing files and other diversions
  • identify files that do not belong to the system
  • enable you to do a proper backup of the important (changed) files only
  • and effectively transform a snowflake to become part of your fleet (IaC)
@blurayne
blurayne / cb.sh
Last active Jan 2, 2020
SSH Remote Forwarded Clipboard
View cb.sh
##
# SSH Remote Forwarded Clipboard
#
# Advantages
# You can copy stuff on a remote machine to your local clipboard (e.g. you could use the script in a shell theme)
# It is not intended to do it the other way round (makes no sense since you usually will use your local clipboard)
#
# Security Concerns
# Someone else on the remote host could spam or exploit your clipboard exploit it (xsel, xclipbaord, parcellite etc.)
#
@blurayne
blurayne / ssh-aws-ec2-instance
Last active Feb 13, 2019
SSH to EC2 using peco and awless
View ssh-aws-ec2-instance
#!/bin/bash
###
# SSH to AWS EC2 instances using peco and awless
#
# - Generate a cache of AWS instances
# - Open peco to select one or more server and either open ssh or tmux-css
# - Does not use `awless ssh` since prefererence on ‘security by obscurity’
#
# Dependencies
View git-ssh.md

Start an ssh-agent

If not yet done add to your rc-file ike .bashrc or .zshrc

$ eval `ssh-agent`

Add your generated key

View git-per-directory-config.md

GitHub.com: GIT Directory-Based Configs

About

So, you are a proud OpenSource developer and work for a company using GitHub.com for GIT repository hosting?

While SSH auth to GitHub.com is based on public keys and it automatically chooses the right account you have to take care when you quickly clone a repository, change something and whoops your company has your private email address or hacker pseudo within their repository.

The scenario we are speaking about looks like following:

@blurayne
blurayne / 01-logging.sh
Last active Jan 23, 2019
Prevent stderr written before stdout
View 01-logging.sh
#!/bin/bash
##
# Logging of bash output and preventing stderr written before stdout
#
# If STDERR is not relvant to yout consider using `exec 1&>>(logger) 2>&1`
#
# Culprit is Unix stdio buffering, as implemented on Linux by glibc which is a system library
# that most programs implemented in C use to handle basic stuff (e.g., IO).
#
You can’t perform that action at this time.