tokssh 1.0 KB

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