Last active
September 18, 2016 03:49
-
-
Save snakevil/c9fb6a906979e3d1afa1f31f4f7f96bb to your computer and use it in GitHub Desktop.
ssh-proxy.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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