Friend,
Recently I needed to perform some maintenance activity on some of my Linux machines.
I got a list of 100 Linux machine.
Problem was that, We haven't configured password-less SSH but the good point is that all Linux machine have same root password. :)
So First I installed "sshpass" command and wrapped ssh over ssh pass on a script.
Below is the sample script to get Uptime of all hosts
================
#!/bin/bash
for i in `cat /tmp/data.txt`
do
sshpass -p 'password' ssh -o StrictHostKeyChecking=no root@$i "hostname;uptime|awk '{print $3,$4}'" >>/tmp/uptime_detail_txt
done
===========================
Where StrictHostKeyChecking is for disable host key checking
Recently I needed to perform some maintenance activity on some of my Linux machines.
I got a list of 100 Linux machine.
Problem was that, We haven't configured password-less SSH but the good point is that all Linux machine have same root password. :)
So First I installed "sshpass" command and wrapped ssh over ssh pass on a script.
Below is the sample script to get Uptime of all hosts
================
#!/bin/bash
for i in `cat /tmp/data.txt`
do
sshpass -p 'password' ssh -o StrictHostKeyChecking=no root@$i "hostname;uptime|awk '{print $3,$4}'" >>/tmp/uptime_detail_txt
done
===========================
Where StrictHostKeyChecking is for disable host key checking
No comments:
Post a Comment