I know the root login/password for a machines, and I want to automate some commands like this from each:
ssh root@remoteHost1 "tail /var/log/messages"
ssh root@remoteHost2 "tail /var/log/messages"
ssh root@remoteHost3 "tail /var/log/messages"
ssh root@remoteHost4 "tail /var/log/messages"
ssh root@remoteHost5 "tail /var/log/messages"
My only problem is that I cant guarantee that the keys and such exist every time, cause there is often re-imaging done without my knowledge... and I dont want to enter "yes" and my password 6 times each time I wanna run my script... so I need to setup something like passwordless ssh but using a script to set it up, and then another script to run my commands... or both in one script, doesn't matter to me...
Is this doable? or is it possible to constantly check STDIN, and when it matches /password\ then I pipe it my password, and if it matches /\(yes\/no\)/ then I know to pipe it "yes"... but then how would I mimic the enter key, cause Im pretty sure "\n" is not enter, but just a new line
any help here?