码迷,mamicode.com
首页 > 系统相关 > 详细

Linux机器添加互信脚本

时间:2017-02-11 11:22:32      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:txt   let   nbsp   suse   bash   sed   send   expect   timeout   

SUSE机器添加互信

#!/bin/bash
num=1
nump=”$num””p”
for i in ‘cat ip.txt’
do
echo “ip:”$i
paswd=’sed –n “$nump” paswd.txt’
echo “passwd:”$paswd
/usr/bin/expect <<EOF
set timeout -1
spawn ssh-copy-id –i /root/.ssh/id_rsa.pub root@$i
expect “*(yes/no)?” {send “yes\r”}
expect “*Password:” {send “$paswd\r”}
expect eof
EOF
Let num++
nump=”$num””p”
done

 

centOS机器添加互信

#!/bin/bash
num=1
nump=”$num””p”
for i in ‘cat ip.txt’
do
echo “ip:”$i
paswd=’sed –n “$nump” paswd.txt’
echo “passwd:”$paswd
/usr/bin/expect <<-EOF
spawn ssh-copy-id –i /root/.ssh/id_rsa.pub root@$i
expect “*Password:” 
send “$paswd\r”
expect eof
EOF
Let num++
nump=”$num””p”
done

 

Linux机器添加互信脚本

标签:txt   let   nbsp   suse   bash   sed   send   expect   timeout   

原文地址:http://www.cnblogs.com/lesliehacker/p/6388693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!