My target is to just validate the login is successful for list of servers in CSV file. For SSH Password, Userid and IP address, I am passing these values via CSV.
And want to capture the result of SSH Connection output after each successful SSH login.
Wrote a shell script for that but, I am seeing successful login output for only the first data set from the CSV. For rest of the servers SSH command is failing.
Script:
#!/bin/sh
INPUT=Test_data.csv
OLDIFS=$IFS
IFS=","
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read ip user pass
do
sshpass -p $pass ssh -n -t -t -o "StrictHostKeyChecking no" $user@$ip >> output.txt
wait
exit
done < $INPUT
IFS=$OLDIFS
Output:
Welcome to CYBER SECURITY
Cisco Codec Release ce 9.12.3 140cd8212ba 2020-04-17
SW Release Date: 2020-04-17
*r Login successful
OK
^[[?1034h10.xx.xx.xx,admin,432584
Command not recognized.
10.xx.xx.xx,admin,432584
Command not recognized.
10.xx.xx.xx,admin,432584
Command not recognized.
10.xx.xx.xx,admin,432584
Command not recognized.

