tokssh 810 B

123456789101112131415161718192021222324252627282930
  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. #
  9. array=( $@ )
  10. len=${#array[@]}
  11. userhost=${array[$len-1]}
  12. args=${array[@]:0:$len-1}
  13. arruserhost=(${userhost//@/ })
  14. arruserhostlen=${#arruserhost[@]}
  15. if [ $arruserhostlen -gt 1 ]
  16. then
  17. # last argument is user@toxid
  18. user=${arruserhost[0]}
  19. toxid=${arruserhost[1]}
  20. ssh -o ProxyCommand="tuntox -i $toxid -P 127.0.0.1:%p" $args $user@localhost
  21. else
  22. # last argument is just toxid
  23. ssh -o ProxyCommand="tuntox -i $toxid -P 127.0.0.1:%p" $args localhost
  24. fi