#!/bin/bash
password=Jdyun@2019
for i in {1..3}
do
expect <<-EOF
set timeout 5
spawn ssh-copy-id -i root@jdc$i
expect {
"yes/no" { send "yes\n";exp_continue }
"password:" { send "$password\n" }
}
interact
expect eof
EOF
done
EOF行前后不能有空格