Skip to content

Instantly share code, notes, and snippets.

@AlexisDucastel
Created June 11, 2014 20:27
Show Gist options
  • Save AlexisDucastel/8d8630f00010aba27ded to your computer and use it in GitHub Desktop.
Save AlexisDucastel/8d8630f00010aba27ded to your computer and use it in GitHub Desktop.
kssh
#!/bin/bash
function die { echo "ERROR: $*"; exit 1; }
[ $# -lt 2 ] && die "Too few arguments"
KNOCKPORTS="$1"
shift
HOST="$1"
shift
for i in $KNOCKPORTS
do
echo "Knock $i ..."
nc -w 1 $HOST $i 2>/dev/null
done
ssh $HOST $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment