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