Skip to content

Instantly share code, notes, and snippets.

@plattrap
Last active April 29, 2019 22:18

Revisions

  1. plattrap revised this gist Apr 29, 2019. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions scan_net.sh
    Original file line number Diff line number Diff line change
    @@ -27,10 +27,6 @@ EOF
    #echo $type :: $key
    }

    #get_ssh_info pi-master

    #exit

    for ADDRESS in $ADDRESSES
    do
    NAME=`wbinfo --WINS-by-ip=${ADDRESS} 2>/dev/null | cut -f2`
  2. plattrap revised this gist Apr 29, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion scan_net.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env bash

    ADDRESSES=`sudo arp-scan --localnet --ignoredups --interface=enp0s25 | grep 172. | cut -f1`
    ADDRESSES=`sudo arp-scan --localnet --ignoredups --interface=enp0s25 | grep $'\t' | cut -f1`

    #echo $ADDRESSES

  3. plattrap revised this gist Apr 29, 2019. No changes.
  4. plattrap revised this gist Apr 29, 2019. No changes.
  5. plattrap created this gist Apr 29, 2019.
    47 changes: 47 additions & 0 deletions scan_net.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/usr/bin/env bash

    ADDRESSES=`sudo arp-scan --localnet --ignoredups --interface=enp0s25 | grep 172. | cut -f1`

    #echo $ADDRESSES

    get_ssh_info () {
    local out err
    {
    out=( $(ssh-keyscan -t ed25519 $1 2>/dev/fd/3) )
    err=( $(cat<&3) )
    } 3<<EOF
    EOF

    if [[ -z ${out[2]} ]]; then
    key=""
    else
    key=${out[2]}
    fi

    if [[ ${err[2]} == "Connection" ]]; then
    host_type="refused"
    else
    host_type="${err[2]} ${err[3]}"
    fi

    #echo $type :: $key
    }

    #get_ssh_info pi-master

    #exit

    for ADDRESS in $ADDRESSES
    do
    NAME=`wbinfo --WINS-by-ip=${ADDRESS} 2>/dev/null | cut -f2`
    if [[ -z "$NAME" ]]; then
    NAME="-"
    fi
    NAME1=`avahi-resolve-address ${ADDRESS} 2>/dev/null | cut -f2`
    if [[ -z "$NAME1" ]]; then
    NAME1="-"
    fi
    get_ssh_info $ADDRESS
    printf "%-15s | %-15s | %-30s | %-8s | %s\n" $ADDRESS $NAME $NAME1 "${key:(-8)}" "$host_type"
    done
    echo