#!/bin/bash ## Tunnel ssh over an XMPP MUC ## ## Server (system with access to the SSH and XMPP server): ## ## # ssh-over-xmpp server ## ssh-over-xmpp server sshxmpp 1.2.3.4 22 ## ## Client (system with access to the XMPP server): ## ## ssh -o ProxyCommand="ssh-over-xmpp client sshxmpp" 127.0.0.1 ## set -o errexit set -o nounset set -o pipefail if [ "$DEBUG" ]; then set -x fi PROGNAME=$0 TMPDIR=$(mktemp -d) out=$TMPDIR/out atexit() { rm -rf "$TMPDIR" } decode() { # shellcheck disable=SC2034 while IFS=: read stanza type from to body; do case "$stanza" in m) printf '%b' "${body//%/\\x}" ;; *) ;; esac done } server() { CONNECT=0 xmppipe -e -r server -o "$1" -b 1024 -x /dev/null } session() { mkdir -p "$TMPDIR" trap atexit 0 mkfifo "$out" nc "$2" "$3" <"$out" | xmppipe -P 100 -r session -o "$1" -x -s | decode >"$out" } client() { xmppipe -P 100 -r client -o "$1" -x -s | decode } # shellcheck disable=SC2068 $@