---
title: "How to Get Info About All the Nodes in the Network via SSH ?"
description: "Logic: 1. Checking if the host is alive. 2. Getting info about them, via remote commands. Steps: 1. Prepare password free."
url: "https://h3manth.com/scribe/how-get-info-about-all-nodes-network-ssh/"
canonical_url: "https://h3manth.com/scribe/how-get-info-about-all-nodes-network-ssh/"
markdown_url: "https://h3manth.com/scribe/blog/how-get-info-about-all-nodes-network-ssh.md"
publishDate: "2010-05-17T00:00:00.000Z"
author: "Hemanth HM"
category: "linux"
tags: ["bash","linux"]
word_count: 203
reading_time_minutes: 2
x_markdown_tokens: 399
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# How to Get Info About All the Nodes in the Network via SSH ?

> Logic: 1. Checking if the host is alive. 2. Getting info about them, via remote commands. Steps: 1. Prepare password free.

**Logic:** _1\. Checking if the host is alive. 2\. Getting info about them, via remote commands._

**Steps:** _1\. Prepare password free SSH access. 2\. Make a simple script to get host info._

**Prepare password free SSH access:** `$ssh-copy-id user@host` or cat ~/.ssh/id_dsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys

**Make a simple script to get host info:** _Step 1. Get the local ip say for eth0. Step 2. Loop the range of ip and check if the host is alive. Step 3. Use ssh to getinfo from /proc_

**Code** ``

## !/bin/bash

user=root getNodeinfo() {

## Get the ip address for the range

ip=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' | cut -d"." -f1,2,3)

## ping test and list the hosts and echo the info

for range in $ip ; do ping -c 1 -w 1 $ip > /dev/null 2> /dev/null >> /tmp/pinglog &&[ $? -eq 0 ] ; echo "Node $range is up" && echo "More info about the machine" ; echo "Kernel:$(ssh $user@$range cat /proc/version)" && echo "CPU info:$(ssh $user@$range cat /proc/cpuinfo )" && echo "Mem info:$(ssh $user@$range cat /proc/meminfo)" && echo "Release:$(ssh $user@$range lsb_release -a)" done } **Got better method?** [Give your idea](https://gist.github.com/24760a1d2066e02ed0a8)
