Skip to content

Instantly share code, notes, and snippets.

View blurayne's full-sized avatar

Markus Geiger blurayne

View GitHub Profile
@blurayne
blurayne / 01-logging.sh
Last active January 23, 2019 23:42
Prevent stderr written before stdout
#!/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).
#

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:

Start an ssh-agent

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

$ eval `ssh-agent`

Add your generated key

@blurayne
blurayne / ssh-aws-ec2-instance
Last active February 13, 2019 20:10
SSH to EC2 using peco and awless
#!/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
@blurayne
blurayne / cb.sh
Last active August 3, 2022 07:27
SSH Remote Forwarded Clipboard
##
# 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 / snowflake-reconnaisance.md
Created June 7, 2019 11:43
Snowflake reconnaisance

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 / ssh-copy-key
Last active July 1, 2022 23:01
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
@blurayne
blurayne / 1-README.md
Last active September 11, 2019 16:52
Variable types in BASH (typeof implementation)

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 / ui-widget-select.sh
Last active March 15, 2024 20:27
Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#!/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 / confluence.lua
Created March 18, 2021 13:57
Pandoc Converters
-- This is a sample custom writer for pandoc. It produces output
-- that is very similar to that of pandoc's HTML writer.
-- There is one new feature: code blocks marked with class 'dot'
-- are piped through graphviz and images are included in the HTML
-- output using 'data:' URLs.
--
-- Invoke with: pandoc -t sample.lua
--
-- Note: you need not have lua installed on your system to use this
-- custom writer. However, if you do have lua installed, you can