diff options
-rwxr-xr-x | scripts/tokssh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/tokssh b/scripts/tokssh new file mode 100755 index 0000000..ef44e3c --- /dev/null +++ b/scripts/tokssh | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # | ||
4 | # A simple wrapper to use like SSH | ||
5 | # Usage: | ||
6 | # tokssh user@5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054 | ||
7 | # tokssh 5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054 | ||
8 | # tokssh -p 2222 -o ForwardAgent=yes user@5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054 | ||
9 | |||
10 | array=( $@ ) | ||
11 | len=${#array[@]} | ||
12 | userhost=${array[$len-1]} | ||
13 | args=${array[@]:0:$len-1} | ||
14 | |||
15 | arruserhost=(${userhost//@/ }) | ||
16 | arruserhostlen=${#arruserhost[@]} | ||
17 | |||
18 | if [ $arruserhostlen -gt 1 ] | ||
19 | then | ||
20 | # last argument is user@toxid | ||
21 | user=${arruserhost[0]} | ||
22 | toxid=${arruserhost[1]} | ||
23 | ssh -o ProxyCommand="tuntox -i $toxid -P 127.0.0.1:%p" $args $user@localhost | ||
24 | else | ||
25 | # last argument is just toxid | ||
26 | ssh -o ProxyCommand="tuntox -i $toxid -P 127.0.0.1:%p" $args localhost | ||
27 | fi | ||
28 | |||
29 | |||
30 | |||
31 | #ssh -o ProxyCommand='tuntox -i %h -P 127.0.0.1:22' $args %r@localhost | ||