Skip to content

Instantly share code, notes, and snippets.

@marc-hanheide
Created October 14, 2020 14:47
Show Gist options
  • Save marc-hanheide/0777c0d97d7795949d7edf14a8d5844c to your computer and use it in GitHub Desktop.
Save marc-hanheide/0777c0d97d7795949d7edf14a8d5844c to your computer and use it in GitHub Desktop.

Revisions

  1. marc-hanheide created this gist Oct 14, 2020.
    7 changes: 7 additions & 0 deletions ssh_scan.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/bin/bash

    SUBNET="10.5.42.0/24
    # compare the output to your ~/.ssh/known_hosts list
    for ip in `nmap -p 22 --open -oG - $SUBNET | grep '22/open' | cut -f2 -d" " `; do key="`ssh-keyscan -H -t rsa $ip 2>&1| grep -v '^# '`"; if [ "$key" ]; then echo "$ip $key"; fi ; done