pre
1. 配置主机直接双向认证
#!/bin/bash USER=`id -un` ssh-keygen -q -N "" -f /$USER/.ssh/id_rsa >/dev/null <<< y thost=() for i in $@ do /usr/bin/expect <<EOF spawn ssh-copy-id -i /$USER/.ssh/id_rsa $USER@$i expect { "*yes/no*" { send "yes\r"; exp_continue } "*assword*" { send "redhat\r" } } expect eof EOF done