首页 > 其他 > 详细

带账号、密码ssh的脚本

时间:2017-02-28 23:06:16      阅读:281      评论:0      收藏:0      [点我收藏+]

带账号、密码ssh的脚本


说明:

1、为expect脚本,后缀建议用.exp(写.sh也没关系)

2、执行需用expect命令

3、登录后可执行想要的命令


$ cat /usr/local/bin/ssh.exp


#!/usr/bin/expexct -f

set ip [lindex $argv 0]

set timeout 10

spawn ssh aa@$ip

expect {

"*(yes/no)*" { send "yes\r"; exp_continue}

"Password:" { send "********\r" }

}

expect "$*"

send "ifconfig | grep addr:10 | cut -b 16-32\r"

send "hostname\r"

send "who | grep MING | head -n 1\r"

send "exit\r"

expect eof


:wq



本文出自 “linux” 博客,请务必保留此出处http://yangzhiming.blog.51cto.com/4849999/1902128

带账号、密码ssh的脚本

原文:http://yangzhiming.blog.51cto.com/4849999/1902128

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!