Wednesday, June 12, 2013

sshpass, A great tool for non-interactive ssh login

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

No comments:

Post a Comment

Renew k8s certificates

Check If certificate expires: amikum@~:03:06:54(⎈ |local-cluster:default):sudo kubeadm certs check-expiration CERTIFICATE                EXP...