Skip to content

Instantly share code, notes, and snippets.

@cjxgm
Last active August 29, 2015 14:16
Show Gist options
  • Save cjxgm/0b34d7aeb6a3482ab3ec to your computer and use it in GitHub Desktop.
Save cjxgm/0b34d7aeb6a3482ab3ec to your computer and use it in GitHub Desktop.
Widow Queen (Gua Fu Wang) automated, ssh tunnel with empty, auto login by password, on OpenWRT
#!/bin/bash
DIR=/tmp
PREFIX=$DIR/widow
PIDFILE=$PREFIX.pid
IN=$PREFIX.in
OUT=$PREFIX.out
echo -e '\e[1;33mkilling ex widow queen...\e[0m'
empty -k $(< $PIDFILE)
echo -e '\e[1;33mconnecting to server...\e[0m'
empty -f -i $IN -o $OUT -p $PIDFILE \
ssh -N -D 0.0.0.0:7070 <user>@<host> -v
empty -w -v -t 60 -i $OUT -o $IN "password:" "" # "(yes/no):" "yes\n"
echo -e '\n\e[1;33mlogging in...\e[0m'
empty -s -o $IN "<password>\n"
empty -w -v -i $OUT -o $IN "interactive session" ""
echo -e '\e[1;32mdone\e[0m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment