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
        echo $ip $host $status >> other
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



foreach($line in Get-Content .\serverList1.txt) {
            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


Your Feedback encourages me

Learning and Developments

One Month Rails

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