这里写自定义目录标题
控制机先执行ssh-keygen -t dsa 一直按回车,
然后执行下列脚本
#!/bin/bash
PASSWORD=主机密码
servername=ip地址文件
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 `cat $servername`
do
auto_ssh_copy_id $SERVER $PASSWORD
done
}
ssh_copy_id_to_all