Check Connectivity to Servers Without Login

- - posted in Technical | Tagged as telnet,ssh,connectivity | Comments

There are times when you would want to check connectivity to your servers without actually login or SSH. You can use telnet on port 22. But here are few other ways:

Linux/Unix - Choose one of the below


#! /bin/bash

rm good no_auth other
while read ip host ; do
    status=$(ssh -o BatchMode=yes -o ConnectTimeout=5 $ip echo ok 2>&1)
    if [[ $status == ok ]] ; then
        echo $ip $host >> good
    elif [[ $status == "Permission denied"* ]] ; then
        echo $ip $host $status >> no_auth
    else
        echo $ip $host $status >> other
    fi
done < $1 

#! /bin/bash
while read ip host ; do
        echo quit | telnet $ip 22 2>/dev/null | grep Connected >> resultsOfTelnetTests.txt

        # OR
        # $ ssh -q -o "BatchMode=yes" skinner "echo 2>&1" && echo $host SSH_OK || echo $host SSH_NOK

        # OR
        # $ ssh -o BatchMode=yes -o ConnectTimeout=5 skinner echo ok 2>&1
done < $1

Windows

Script
=====

foreach($line in Get-Content .\serverList1.txt) {
      try{
            test-connection $line -Count 1 -Delay 2 -TTL 255 -BufferSize 256 -ThrottleLimit 32 | Select Address,IPv4Address,ResponseTime,BufferSize
      }catch [Exception] {
            echo .$line Not reachable.
      }
}


Serverlist1.txt contains the hostnames, one hostname in one line.




Gravatar of Ashwani Kumar

Recent posts


Subscribe



Your Feedback encourages me




Learning and Developments

One Month Rails



, 2FA, AWS AWS, Active Authenticator Directory, Facebook Flash, Forwarding, GOD,Chat,Coffee Github,Feedback,Repo Google Google,Search HAProxy, IOT, IP-block JQuery LetsEncrypt Load MQ MQTT, Messaging Octopress Octopress, OpenVpn OpenVpn, PI, Plugin Plugin, Port Raspberry, S3, SSH, Shell,Commands Soapui, Tag Tag, Tree, Tunneling XML XML, XServer, Xming ajax, angular, animated architecture architecture, azure balancing cloud, commenting, connectivity datapower datatables diagrams diaspora dropdown geocoding grep, hashicorp, ipaddress, ipv6, java, java,python mysql nokogiri, octopress-migration octopress-plugin openapi, openssl powershell proxy rails, repo reviews ruby, script scripts, security, sharepoint shell spring springboot, ssh, swagger, telnet, vault vi, vieditor vim, visualblock, webattacks windows,cleanup windowsxp