1、编写txt文本文件
#!/usr/bin/expect -f
set user 用户名
set port 端口
set host url
set password 密码
set timeout -1
spawn ssh $user@$host -p $port
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "$password\r"}
}
interact
expect eof
客户端配置
Profiles=>选择Command
内容填入:expect 绝对路径.txt
2、编写.sh脚本
#!/usr/bin/expect
set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 3]\n"}
}
expect "~"
send "clear\n"
interact
客户端配置
profiles=》选择login shell
绝对路径.sh 端口 用户名 url 密码