title: How to find if remote host is reachable over SSH without actually doing ssh
body: <p>I have multiple remote hosts connected to my local host (server-A).  TO ensure/filter the list of hosts which are genuinely reachable to localhost , I do ping test. </p>
  
  <pre><code>ping -c1 &lt;remotehost-IP&gt; 
  
  if [ "$?" != "0" ];then
  echo "Not reachable.Exiting..."
  exit 1;
  fi
  </code></pre>
  
  <p>However ping test could not provide me any check to ensure that filtered remotehost-IPs are reachable over SSH connection /port 22. </p>
  
  <pre><code>    non-root-user@localhost&gt;ssh 172.26.192.15
      ssh: connect to host 172.26.192.15 port 22: Connection refused
   non-root-user@localhost&gt;echo $?
   1
  
  non-root-user@localhost&gt;ssh -v  172.26.192.15
  OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
  debug1: Reading configuration data /etc/ssh/ssh_config
  debug1: Applying options for *
  debug1: Connecting to 172.26.192.15 [172.26.192.15] port 22.
  debug1: connect to address 172.26.192.15 port 22: Connection refused
  ssh: connect to host 172.26.192.15 port 22: Connection refused
  </code></pre>
  
  <h1>Query:</h1>
  
  <p>Above check work for me if connection is refused. However, if SSH connection is possible then I enter into the remote host or proceed to password prompt. Which cause barrier to check return code. </p>
  
  <p>So I wanted to know if there is any way to check if the remote IP WOULD be reachable or not reachable over SSH beforehand. ? </p>