It's too dangerous to go alone. Take this.

Archive for February, 2011

Ghetto copy/paste

A lot of times, I SSH from one machine into another and end up in a shell maybe three or four ssh “links” away from my current machine. Then, innocently enough, I’d like to copy a file between that machine and my current machine. Invariably, there’s the pang of laziness as I contemplate how to hook up the necessary SSH pipeline so that I can perform the scp. And, since we all know that laziness is the father of invention, I was inspired to write some simple shell scripts.


#!/usr/bin/env bash

if [ ! -f "$file" ]; then
    echo "usage: $0 <file>" 1>&2
    exit 1

cat "$file" | bzip2 - | openssl enc -a


#!/usr/bin/env bash

out=${1:-$(mktemp ghetto.XXXXXX)}
openssl enc -d -a | bunzip2 - > $out

These scripts allow me to use the clipboard to copy/paste most reasonably-sized files. It won’t work on huge files (or big files that don’t compress very well) but it will simplify moving annoyingly large binary files. Enjoy!