#!/bin/bash
hostnames='admin node1 node2 node3'
passwords='1234 1235 1236 1237'
for i in $hostnames
do
for j in $passwords
do
sshpass -p $j ssh-copy-id root@$i -p 22
done
done
While running this script I realized that every element from host-names is tried with passwords.
How can I make it so that the first element from host-names matches with the first element from passwords then 2nd element with 2nd element and so on instead of matching each element from host-names to every element from passwords?
Also is it possible to fetch host-names and passwords from a file instead of declaring them like i did in my code?