Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
#
#<UDF name="ssuser" Label="Sudo user username?" example="username" />
#<UDF name="sspassword" Label="Sudo user password?" example="strongPassword" />
#<UDF name="sspubkey" Label="SSH pubkey (installed for root and sudo user)?" example="ssh-rsa ..." />
# initial needfuls
apt-get -o Acquire::ForceIPv4=true update
@craigphicks
craigphicks / dtdotool.sh
Last active December 27, 2020 08:04
Used in Ubuntu 18.04 to manipulate desktops as atomic elements of an array, e.g., swapping element order, inserting and deleting empty elements.
#!/bin/bash
# Copyright (c) 2019, Craig P Hicks
# content licensed as CC BY-NC-SA
# CC BY-NC-SA details at https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
# This program depends upon 'xdotool' installed as Ubuntu 18.04 managed package
# xdotool project source can be found at:
# https://github.com/jordansissel/xdotool
# https://www.semicomplete.com/projects/xdotool/
@craigphicks
craigphicks / OpenWrt-Package-Downloader.py
Last active April 25, 2019 21:57 — forked from lanceliao/OpenWrt-Package-Downloader.py
Cache all packages from OpenWrt trunk repository
#!/usr/bin/env python2
#coding=utf-8
#
# Openwrt Package Grabber
#
# Copyright (C) 2014 http://www.shuyz.com
# modified 2019 craigphicks
#
import urllib2
@craigphicks
craigphicks / setup-openwrt-rpi3bplus-and-nftables.md
Last active April 24, 2019 19:09
Setting up openwrt to run on Paspberry Pi 3 B+ - and replacing `iptables` with `nftables`
@craigphicks
craigphicks / iptree.py
Last active April 7, 2020 10:52
Convert `iptables -S` output to a depth-first tree listing
#!/usr/bin/env python3
'''
Convert `iptables -S` output to a depth-first tree listing
Reads from standard input
Craig P Hicks 2019
MIT License
'''
import sys
@craigphicks
craigphicks / howto-ssh-pipe.md
Last active April 6, 2019 02:49
Set up an ssh pipe

Setting up a pipes between A and B

A to B (setup on A)

From A, set up a pipe for sending data from A to B

a@A: ssh -v -N -L 2223:127.0.0.1:2222 b@B

To test it, first open a listener on B

@craigphicks
craigphicks / script.py
Last active March 26, 2019 23:00
python3 Script to create instance of LDX container with debian stretch from linuxcontainers and configure it up to ssh-login-ability
#!/usr/bin/env python3
import argparse
import textwrap
import subprocess
import os
import datetime
#import pdb
#import random
import time
@craigphicks
craigphicks / secure-ssh-copy-to-remote-server.md
Last active March 12, 2019 23:06
How to send data to local clipboard from a remote SSH session

secure ssh copy to remote server

motivation

From machine A, user-A does an sshinto th eaccount user-B on server B for a terminal session.
In the course of that session, it would be convenient to copy some data to A's clipboard, without using mouse to drag and click. Example use cases:

  1. cat files content into local clipboard. C.f., cat | xsel -i -b or cat | xclip -i -selection b
@craigphicks
craigphicks / call-pymd.py
Created March 10, 2019 00:40
Read a yaml conf file with markdown extensions and use that to format python-markdown command line
import yaml
#import pdb
import sys
import subprocess
import pprint
fn_mdin = "./mdext.yml"
fn_mdcfgtmp = "./tmp/mdext-CFG.yml"
fn_scr="./call-pymd.out"
@craigphicks
craigphicks / multi os booting with systemd-boot.md
Last active March 6, 2019 10:05
multi os booting with `systemd-boot` / `boot-ctl` --- case examples: LVM, LUKS with LVM, on SSD

multi os booting with systemd-boot

We set up multiple OS to be booted from a UBS SD.

Both are Ubuntu.

  • ub16 is on an LVM2 partition.
  • ub18 is on an encrypted LUKS partition with LVM2 on the inside. As it happen, the disk is SSD.

Formatting the USB SD