Reputation: 796
not an linux expert but I´m trying to see a way of using a bash script to check connectivity tu multiple servers and avoid any human intervention.
I have something like this, so that I can connect to a host, execute hostname and put that info in a log
#!/bin/bash
for host in $(cat server.txt)
do
ssh -q -o ConnectTimeout=3 "$host" "hostname"
done > servers.log
Is this possible to execute and avoid the
ECDSA key fingerprint is a3:eb:a8:4d:90:1d:ae:83:bc:7b:a9:47:69:67:67:7f.
Are you sure you want to continue connecting (yes/no)?
?
or just to force toy say YES?
thank you
Upvotes: 0
Views: 528
Reputation: 785068
To suppress this warning in ssh
command use:
ssh -o "StrictHostKeyChecking=no" user@host
Also use while read
loop instead of for
loop like this:
while read -r host; do
ssh -tt -oBatchMode=yes -o "StrictHostKeyChecking=no" "user@$host"
done < server.txt > servers.log
Upvotes: 3