item2实现ssh的免密登录,item2实现ssh


编写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 打开设置


img_b64801f6cf9d782fcf7bf791cc26c706.png

2 参数配置

/Users/miaogaolin/Documents/ssh-info.sh [端口号] [用户名] [服务器IP] ['密码']
img_eff78df0faca18207e5e69e586ddeeda.png

3 开始连接

方式一:command + o
方式二:如下图

img_0a982ba34c8dbd8b4b76217d7c936019.png

相关内容