标签:linux
安装expect,RHEL和CentOS系统光盘自带。
yum -y install expect
创建主机ip列表文件host.txt
cat >> host.txt << EOF 192.168.100.2 192.168.100.3 192.168.100.4 192.168.100.5 192.168.100.6 192.168.100.7 192.168.100.8 192.168.100.9 192.168.100.10 EOF
执行ssh-keygen后面一直回车直到结束。
ssh-keygen
新建自动创建信任关系脚本,其中root-123为所有主机登录密码。
#!/bin/bash cat host.txt | while read host do /usr/bin/expect << EOF spawn ssh-copy-id root@$host expect { "yes/no" { send "yes\r"; exp_continue} "password:" { send "root-123\r" } } expect eof EOF done
本文出自 “12092929” 博客,谢绝转载!
标签:linux
原文地址:http://12102929.blog.51cto.com/12092929/1975585