expect ssh首次登录自动判断 yes/no

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               
v-lhb-prx01:/root/sbin# sh ./expect.sh spawn ssh [email protected] authenticity of host '192.168.32.16 (192.168.32.16)' can't be established.RSA key fingerprint is da:3a:61:09:e4:f6:46:d7:01:08:1a:6c:b9:41:e8:4c.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.32.16' (RSA) to the list of known [email protected]'s password: Last login: Wed May 27 09:37:32 2015 from 192.168.33.107v-dev-redis02:/root# df -hFilesystem                Size  Used Avail Use% Mounted on/dev/mapper/vg00-lv_root  7.75.61.877% /tmpfs                     499M     0  499M   0% /dev/shm/dev/sda1                 194M   2915516% /bootv-dev-redis02:/root# exitlogoutConnection to 192.168.32.16 closed.-----------------------------------------------------------------------------------expect {    "(yes/no)?" {        send "yes\n"        expect "password:"        send "$passwd\n"    }        "password:" {        send "$passwd\n"    } }# 下面测试是否登录到 expect "#" send "df -h\n"send "exit\r"expect eof

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/trigfj/article/details/84195727