A
ssh-keygen
ssh-copy-id A
scp -rp /root/.ssh B:/root/
scp -rp /root/.ssh C:/root/
[root@centos6 ~]#cat ssh_key.sh <<EOF
#!/bin/bash rpm -q expect &> /dev/null || yum install
expect -y ssh-keygen -P "" -f "/root/.ssh/id_rsa"
password=centos
while read ipaddr;do
expect <<EOF
set timeout 10
spawn ssh-copy-id $ipaddr
expect { "yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" } }
expect eof EOF done < ip.txt
EOF
awk '/Failed password/{ip[$(NF-3)]++}END{for(i in ip) {if(ip[i]>=3)system("iptables -A INPUT -s " i " -j REJECT") }}' /var/log/secure #登录失败三次拒绝登录
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/boot.iso /data/myiso/
标签:ip,三台,boot,ssh,key,主机,password,root,expect From: https://www.cnblogs.com/xuxuxu-2022/p/17554798.html