(2)
#!/bin/bash
set timeout 30
for i in `cat ./serverlist.ini |grep "="|awk -F= '{print $2}'`
do
echo $i
expect< spawn ssh root@$i ""
expect "Are you sure you want to continue connecting (yes/no)? "
send "yes\n"
expect eof
exit
END
done
(3)
#!/bin/bash
set timeout 30
expect
send "\n"
expect "Overwrite (y/n)? "
send "\n"
expect eof
exit
END
for i in `cat ./serverlist.ini |grep "="|awk -F= '{print $2}'`
do
# echo $i
expect<# spawn scp /root/.ssh/id_rsa.pub [email protected]:.ssh/id_rsa.pub
# expect "password: "
# send "km@123\n"
spawn ssh root@$i "mkdir /root/.ssh/"
expect "password: "
send "123456789\n"
expect eof
exit
END
expect< spawn scp /root/.ssh/id_rsa.pub root@$i:/root/.ssh/id_rsa.pub
expect "password: "
send "123456789\n"
expect eof
exit
END
expect< spawn ssh root@$i "touch /root/.ssh/authorized_keys"
expect "password: "
send "123456789\n"
expect eof
exit
END
expect< spawn ssh root@$i "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys"
expect "password: "
send "123456789\n"
expect eof
exit
END
# #scp *.sh $i:/root/
done
#set timeout 30
#spawn ssh [email protected]
#expect "password: "
#send "df@123\n"
#expect {
# "(yes/no)?" {
# send "yes\n"
#
# }
# "pwd:"{
# ...
# }
#}
#expect{
# "yes/no" {send "yes\r"; exp_continue}
# "pwd:{send"abc\n"}"
#}