编写expect脚本
1 新建脚本(脚本位置没有明确要求)
touch ssh-info.sh
2 脚本内容
#!/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"}
}
interact
item2工具设置
1 打开设置

2 参数配置
/Users/miaogaolin/Documents/ssh-info.sh [端口号] [用户名] [服务器IP] ['密码']

3 开始连接
方式一:command + o
方式二:如下图
