1 #!/usr/bin/expect 2 set timeout 10 3 spawn ssh root@20.0.102.19 4 expect "password:" 5 send "123456 " 6 interact
1 #!/usr/bin/expect 2 set timeout 10 3 spawn scp -r /root/authorized_keys root@20.0.102.19:/root/.ssh/authorized_keys
#将本地的authorized_keys拷贝到远端的/root/.ssh
4 expect "password:" 5 send "123456 " 6 interact
今天要用expect免密码登陆集群中节点,使用expect实现免密码登陆和scp.