Skip to content

Instantly share code, notes, and snippets.

@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

@craigphicks
craigphicks / clip.md
Created March 2, 2019 10:47
A piece of md with nested <details> blocks that wond parse with markdown.extra or pymdownx.extra
## Full example with *lighttpd v1.4.45* and *Firefox v65.0*
@craigphicks
craigphicks / privca.sh
Last active March 13, 2019 10:11
Create private CA and server/client certs for 2-way auth secure closed networks. See https://github.com/craigphicks/privca
#!/bin/bash
#
# craigphicks copyright 2019 - MIT license
# see https://github.com/craigphicks/privca
set -u
Existing_CA_CN=""
function _get_CA_CN {
@craigphicks
craigphicks / make-cert.sh
Last active October 26, 2019 01:34
self managed private CA and certs - no config files, two levels only, no intermediate, no revocation list, file names are CN - ideal for personal IoT
#!/bin/bash
# craigphicks 2019
set -u
function CreateCertificateAuthority {
if [[ $# -ne 2 ]] ; then
echo "two args only: CA common name, CA org name"
exit 1
fi
CA_CN=${1}
PasswordSafe database format description version 3.31
-----------------------------------------------------
Copyright (c) 2003-2016 Rony Shapiro <ronys@pwsafe.org>.
All rights reserved. Use of the code is allowed under the Artistic
License terms, as specified in the LICENSE file distributed with this
code, or available from
http://www.opensource.org/licenses/artistic-license-2.0.php
@craigphicks
craigphicks / sendmail-mailgun.py
Last active July 13, 2018 22:20
python 40 line drop-in replacement for sendmail/postfix etc - avoid setting files when only using mail to send system notifications to fixed address
#!/usr/bin/env python3
import os
import sys
import subprocess
s = ""
s += "---- begin args ----\n"
for i in range(0,len( sys.argv )):
s+= "argv[" + str(i) + "]:" + str(sys.argv[i]) +"\n"