Posted By

miceno on 04/23/13


Tagged

Bash ssh


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ab1


Bash SSH Tunnel


 / Published in: Bash
 

This script opens an SSL tunnel between a source host and a target host.

  1. #!/usr/bin/env bash
  2. if [ -z "$1" -o "$1" = "-h" ]; then
  3. echo "$(basename $0): [ [SOURCE_HOST [SOURCE_PORT [TARGET_HOST [TARGET_PORT [USERNAME] ] ] ] ] ]"
  4. exit 0
  5. fi
  6. SOURCE_HOST=${1:-0.0.0.0}
  7. SOURCE_PORT=${2:-7722}
  8. TARGET_HOST=${3:-localhost}
  9. TARGET_PORT=${4:-22}
  10.  
  11. USERNAME=${5:-bewifi@localhost}
  12. DEBUG=""
  13. #DEBUG=echo
  14.  
  15. $DEBUG ssh -f "$USERNAME" -L $SOURCE_HOST:$SOURCE_PORT:$TARGET_HOST:$TARGET_PORT -N

Report this snippet  

You need to login to post a comment.