Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save congzhangzh/ebdf4c6e330ead989de320098c8e3e50 to your computer and use it in GitHub Desktop.
Save congzhangzh/ebdf4c6e330ead989de320098c8e3e50 to your computer and use it in GitHub Desktop.
Open Port Knock Guarded SSH Port with Netcat
#tips:
#sometimes, use udp and send by parallel is the only way, if you behind a proxy

#----------------------nc way-----------------------------
## input part
SSH_HOST=your_host_ip 

# --way 1-- direct 
for PORT in $PORT1 $PORT2 $PORT3; do nc -vz $SSH_HOST $PORT; done; ssh $SSH_USER@SSH_HOST

# --way 2-- give it some delay
for PORT in $PORT1 $PORT2 $PORT3; do nc -vz $SSH_HOST $PORT; sleep 0.1;  done; ssh $SSH_USER@SSH_HOST

# --way 3-- do as parallel as possible, for some env
for PORT in $PORT1 $PORT2 $PORT3; do bash -c "nc -vz $SSH_HOST $PORT &";  done; ssh $SSH_USER@SSH_HOST
#----------------------nmap way todo-----------------------------
#----------------------knock way todo-----------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment