Bash SSH Tunnel


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.