Need to check login across multiple servers

I need to manually interactively feed in my password for each server one after the other. Below is the script I am using:

#!/bin/bash
input="serverlist.txt"
while IFS= read -r var <&3
do
echo $var
ssh user1@$var
done 3< "$input"

I get password prompt for the first server. If I dont have access and I try to come out of the password prompt using Ctrl+D or Ctrl+C the script terminates rather than prompting me for the next server and so forth.

I know expect is ideal for such a requirement but I have no idea as i never worked with expect .

Can someone please help suggest?

Ideal to use password-less ssh as I informed you in your other post on this topic.

1 Like