Created
          May 3, 2020 14:49 
        
      - 
      
 - 
        
Save dangtrinhnt/821eb6b513ce27cf213f5aa019b969b2 to your computer and use it in GitHub Desktop.  
    Create a sock proxy at a random port that helps you to connect to a private network from your computer
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #! /bin/bash | |
| SSH_KEY=$1 | |
| BASTION_IP=$2 | |
| USERNAME=$3 | |
| PROXY_PORT=`comm -23 <(seq 13000 13999 | sort) <(netstat -tan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1` | |
| ssh -i "$SSH_KEY" -CND "${PROXY_PORT}" -q "${USERNAME}@${BASTION_IP}" & | |
| echo "socks5://localhost:$PROXY_PORT" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment