blob: 6bdb74db0e9bc572e6695c8c57a654998c5d8c9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/bin/bash
#
# A simple wrapper to use like SSH
# Usage:
# tokssh user@5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054
# tokssh 5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054
# tokssh -p 2222 -o ForwardAgent=yes user@5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054
# tokssh user@5A40C3443ABD6E1DDEE682E83F84A4D556C24C22D2230DCC141A4723C123473C171A4D9C4054 -s TuNToXSeCreT
#
array=( $@ )
len=${#array[@]}
userhost=${array[$len-1]}
args=${array[@]:0:$len-1}
if [ "${array[$len-2]}" == "-s" ]
then
secret="${array[@]:$len-2:$len-1}"
len=$[len-2]
fi
arruserhost=(${userhost//@/ })
arruserhostlen=${#arruserhost[@]}
if [ $arruserhostlen -gt 1 ]
then
# last argument is user@toxid
user=${arruserhost[0]}
toxid=${arruserhost[1]}
ssh -o ProxyCommand="tuntox -i $toxid -W 127.0.0.1:%p $secret" $args $user@localhost
else
# last argument is just toxid
ssh -o ProxyCommand="tuntox -i $userhost -W 127.0.0.1:%p $secret" $args localhost
fi
|