#!/bin/bash
SERVERS="192.168.199.130 192.168.199.131 192.168.199.132 192.168.199.134 192.168.199.135 192.168.199.136"
PASSWORD=redhat
auto_ssh_copy_id() {
expect -c "set timeout -1;
spawn ssh-copy-id $1;
expect {
*(yes/no)* {send -- yes\r;exp_continue;}
*password:* {send -- $2\r;exp_continue;}
eof {exit 0;}
}";
}
ssh_copy_id_to_all() {
for SERVER in $SERVERS
do
echo $SERVER $PASSWORD
auto_ssh_copy_id $SERVER $PASSWORD
done
}
ssh_copy_id_to_all
SERVERS="192.168.199.130 192.168.199.131 192.168.199.132 192.168.199.134 192.168.199.135 192.168.199.136"
PASSWORD=redhat
auto_ssh_copy_id() {
expect -c "set timeout -1;
spawn ssh-copy-id $1;
expect {
*(yes/no)* {send -- yes\r;exp_continue;}
*password:* {send -- $2\r;exp_continue;}
eof {exit 0;}
}";
}
ssh_copy_id_to_all() {
for SERVER in $SERVERS
do
echo $SERVER $PASSWORD
auto_ssh_copy_id $SERVER $PASSWORD
done
}
ssh_copy_id_to_all