Skip to content

Instantly share code, notes, and snippets.

@Juul
Juul / ssh-copy-id-openwrt
Last active August 23, 2023 11:10
ssh-copy-id but for openwrt / dropbear
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Example: ${0} root@192.168.1.1"
exit 1
fi
cat ~/.ssh/id_rsa.pub | ssh ${1} "cat >> /etc/dropbear/authorized_keys && chmod 0600 /etc/dropbear/authorized_keys && chmod 0700 /etc/dropbear"
@Juul
Juul / sshudo
Last active May 5, 2016 18:12
sshudo
#!/bin/sh
# Download SSH public key for sudo room user from sudo-humans
BASE_URL="https://sudoroom.org/humans"
MAX_TIME="5" # Fail if download takes longer than this (in seconds)
GET_CMD=""
if [ "$#" -ne "1" ]; then
echo "Usage: sshudo <username>" >&2
#!/bin/bash
# Run this in an existing git-tracked directory to set up
# a remote repo on hostname.
#
# Usage: ./git_setup hostname
#
# This assumes you have ssh key-based login access as the user 'git'
# on the remote server. If this is not the case,
# change the GITUSER variable below:

Open source remote encrypted full-system backups

A while back I had my laptop stolen and while I had backups of all the important stuff my latest full-system backup was several months old since I have to dig out my backup harddrive from its alternate location every time I want to update the backup (I don't store my laptop and backup harddrive in the same building since theft/fire would mean loosing all copies).

So, being sick of imperfect backup solutions I decided to find a solution for online full-system backups that met the following criteria:

  • 100% open source client
  • Zero-knowledge encryption (server can't access data)
  • Works on GNU/Linux
  • Affordable (max $20 per month for ~1TB)
@Juul
Juul / hackintosh-z220.md
Created April 12, 2016 00:24
juul's hackintosh guide

Here's some quick notes on how to build a cheap high-performance hackintosh. This guide is made so you can start with ~$400 and get a useful working system, then upgrade a bit at a time to arrive at a ~$1k powerful machine that will do HD/4k video color grading.

The only real disadvantage to this system over a real iMac is that it takes effort and forethought to upgrade to new versions of OS X.

Specs:

CPU: Xeon E3-1240v2 Quad-core 3.4 GHz
RAM: 32 GB
HD 1: 500 GB solid state
@Juul
Juul / ash-timeout-prompt.ash
Created May 5, 2016 13:37
An ash shell script (busybox) for a user prompt with timeout
#!/bin/ash
# This script waits for three seconds for the user to press any key
# that generates a character (other than enter) and otherwise
# proceeds normally
#
# This is an ash shell script for use in e.g. a busybox initrd
# to allow letting the user boot into a rescue environment (e.g. the initrd itself)
#
# This script requires: dd, stty, grep, cut, kill and sleep
@Juul
Juul / trippy.cat.js
Created August 18, 2016 12:31
trippy.cat
#!/usr/bin/env node
// To use first run: npm install colors through2
var colors = require('colors');
var through = require('through2');
var ins;
if(process.argv.length > 2) {
var fs = require('fs');

The banana pi m1 works with the cheap ~$15 chinese 5 port sata multipliers.

Warning: The multipliers will get really hot and unreliable under load or if more than three drives are attached. Definitely put at least a heatsink on it.

With the official bananian distro it appears to work out of the box but it unfortunately only works with one drive at a time.

To get it working with multiple drives you need to enable the sunxi pmp support. The reason this is not enabled per default is that when it is enabled you will be unable to use the sata port without a port multiplier.

The kernel in the official bananian distro does not have sunxi pmp support compiled into it and the kernel is too old anyway.

@Juul
Juul / ssh_encrypt_file.sh
Last active March 30, 2017 02:06
Encrypt a file with an ssh public key and include instructions on how to decrypt
#!/bin/bash
# ToDo
#
# * make it work for non-rsa keys
# * support encrypting multiple files at once
# * add support for other pubkey sources than github
if [ "$#" -ne "2" ]; then
@Juul
Juul / leveldump.js
Last active July 2, 2019 21:48
Simple tool to dump the contents of leveldb databases
#!/usr/bin/env node
var fs = require('fs');
try {
var level = require('level');
} catch(e) {
console.error("You must have the node module `level` installed.");
console.error("To install run: `npm install level`");
process.exit(1);