expect脚本免密码


1 #!/usr/bin/expect 2 set timeout 10 3 spawn ssh root@20.0.102.19 4 expect "password:" 5 send "123456\n" 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\n" 6 interact

 今天要用expect免密码登陆集群中节点,使用expect实现免密码登陆和scp.

posted @ 2017-01-16 20:05  子非木  阅读(513)  评论(0编辑  收藏  举报