Skip to content

Instantly share code, notes, and snippets.

@snakevil
Last active September 18, 2016 03:49
Show Gist options
  • Save snakevil/c9fb6a906979e3d1afa1f31f4f7f96bb to your computer and use it in GitHub Desktop.
Save snakevil/c9fb6a906979e3d1afa1f31f4f7f96bb to your computer and use it in GitHub Desktop.
ssh-proxy.sh
#!/bin/sh
#
# Proxy agent script, for 'ProxyCommand' directive in 'ssh_config'.
#
# Usage:
# ssh-proxy.sh <Origin Host> <Origin Port> [<Alternative Host> [<Alternative Port>]]
#
# Example:
# ProxyCommand ssh-proxy.sh %h %p ddns.host.name
#
# AUTHOR Snakevil Zen <[email protected]>
# COPYRIGHT 2016 szen.in
Host="$1"
Port="$2"
[ -z "$3" ] || {
/sbin/ping -c1 -s1 -t1 $Host || {
Host="$3"
[ -z "$4" ] || Port="$4"
}
}
/usr/bin/nc "$Host" "$Port" 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment