diff options
author | makefu <github@syntax-fehler.de> | 2011-11-29 17:09:23 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2011-11-29 17:09:23 +0100 |
commit | f80d7eb87f8916601347168604b86e719d9df105 (patch) | |
tree | 9df2a69e7804f05830bb2518b37a9d45a58a1e20 /util/bin/sshkill | |
parent | ed55e0bc475e77c20eb25f09df8c1b13c415d69f (diff) | |
parent | 41d1e4da237c87f88752adfc1b648ebf15df5af1 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'util/bin/sshkill')
-rwxr-xr-x | util/bin/sshkill | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/util/bin/sshkill b/util/bin/sshkill new file mode 100755 index 00000000..80300483 --- /dev/null +++ b/util/bin/sshkill @@ -0,0 +1,33 @@ +#! /bin/sh +# +# kill ssh client: sshkill user@host:port +# setup bash completion: . sshkill +# +if ! grep -q '^ControlPath /tmp/%u/sshmux/%r@%h:%p$' "$HOME/.ssh/config"; then + echo "Your ~/.ssh/config's ControlPath sucks!" >&2 + (exit 23) +else + if test "${0:0:1}" = -; then + if ! echo "${BASHOPTS-}" | grep -Eq '(^|:)progcomp(:|$)'; then + echo "source sshmux into something other than a progcomp'able bash" >&2 + (exit 23) + else + + # setup bash completion + comp_sshkill() { + if test $COMP_CWORD = 1; then + COMPREPLY=($(cd "/tmp/$LOGNAME/sshmux" && + ls | grep "^${COMP_WORDS[$COMP_CWORD]}.*")) + fi + } + complete -F comp_sshkill sshkill + + fi + else + + # kill ssh client + set -euf + exec pkill -f "^ssh: /tmp/$LOGNAME/sshmux/$1 \[mux\]$" + + fi +fi |