Skip to content

Instantly share code, notes, and snippets.

@n1mh
Created November 30, 2016 09:13
Show Gist options
  • Save n1mh/43843ad5e57c556657c3b6315441d53a to your computer and use it in GitHub Desktop.
Save n1mh/43843ad5e57c556657c3b6315441d53a to your computer and use it in GitHub Desktop.
checking open ports using bash
#!/bin/bash
# adapted from:
# https://stackoverflow.com/questions/9609130/quick-way-to-find-if-a-port-is-open-on-linux#9609247
# exec 6<>/dev/tcp/ip.addr.of.server/445
# echo -e "GET / HTTP/1.0\n" >&6
# cat <&6
( exec 6<>/dev/tcp/127.0.0.1/22 && echo 'ssh open!' )|| echo 'ssh closed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment