Skip to content

Instantly share code, notes, and snippets.

@timkuijsten
timkuijsten / agent.sh
Created October 4, 2011 20:48
load a private key for 24 hours in the ssh-agent
# if we have private keys, load ssh-agent or connect to an already running agent
if [ -r $HOME/.ssh/id_rsa -o -r $HOME/.ssh/id_dsa -o -r $HOME/.ssh/identity ]; then
SSH_SOCKET=$HOME/.ssh/.ssh-socket
# ensure socket
ps -cx | grep -q '[s]sh-agent'
if [ 0 -ne $? ]; then
old_umask=$(umask)
umask 0077
@timkuijsten
timkuijsten / .bash_profile
Last active September 27, 2015 04:08
tab complete ssh with known hosts
if [ -f ~/.ssh/known_hosts ]; then
HOSTLIST=$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | sed -e 's/^\[\(.*\)\].*/\1/g' | egrep -v '^[0-9]' | uniq`;)
complete -o bashdefault -o default -W "${HOSTLIST}" ssh
complete -o bashdefault -o default -o nospace -W "${HOSTLIST}" scp
complete -o bashdefault -o default -o nospace -W "${HOSTLIST}" ping
fi
@timkuijsten
timkuijsten / tunnel.sh
Created September 9, 2011 11:53
os x ssh proxy
#!/bin/sh
#
# Copyright (c) 2011 Netsend
# Released under the MIT license.
#
###
# create a local ssh SOCKS proxy to RHOST and update OS X proxy settings.
# Tip: make your programs use the default OS X proxy.
#####
@timkuijsten
timkuijsten / random_hash_b62
Created August 10, 2011 19:31
random_key base 62
<?php
/*
* Copyright 2011, Tim Kuijsten
* Released under the MIT license.
* http://creativecommons.org/licenses/MIT/
*/
/**
* Generate a random string of base 62 characters [a-zA-Z0-9].
*