Is it possible to create a script that can ssh to multiple hosts one after another (not parallel) and wait till I exit the existing ssh session?
I've 50+ hosts. Here are the steps:
- SSH host 1
- From host 1 command prompt, run a set of operations (manually) and exit the session (manually).
- The script automatically detects the exit and SSH to the next host.
Trying to make use of the existing tools in rhel 6.x. I was just wondering if someone has done it with built-in tools
I could do something like this: but I just need to know how to make the script to wait till I finish the operations.
usr=test
svrs=("192.168.18.48" "192.168.191.237" )
for x in ${!svrs[*]} ; do
ip=`echo ${svrs[x]}`
ssh $usr@$ip
done
echo ${svrs[x]}and use$(...)instead.expectscript. Although this can get tedious rather quickly. If you try to automate administration tasks, it is probably better to distribute script that does what you want onto the machines - you can always use some management tool to keep it versioned and synced across all hosts.