Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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/
#!/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 / X11-over-ssh-without-xauth.md
Created July 6, 2019 19:01
Forwarding `X11` over `ssh` without using `xauth`

Forwarding X11 over ssh without using xauth

  • local -- the local machine serving an Xserver.
  • remote -- the remote machine serving the application which drives the data going to the Xserver

Remote /etc/ssh/sshd_config:

X11Forwarding no
X11DisplayOffset 10
X11UseLocalhost yes
@craigphicks
craigphicks / setTimeout-args-bind-scope.md
Created July 10, 2019 21:12
testing javascript setTimeout args, bind, scope.
x=10;
function test(){
  var x=20;
  var obj = {x:30};
  function logargs(t,arg1,arg2,arg3,arg4) { 
    console.log(`(${t}) this.x=${this.x},x=${x},obj.x=${obj.x},${arg1},${arg2},${arg3},${arg4.x}`); 
  }
  logargs("A",this.x,x,obj.x,obj);
 setTimeout(logargs,0,"B",this.x,x,obj.x,obj);