访问排行榜
谷歌广告
谷歌广告
Mac 让 iTerm2 记住SSH用户名密码 expect 脚本
Author 沐青之枫 | Posted 2018-03-05 16:00:00

转载地址:www.jianshu.com/p/3757554b907d

/usr/local/bin目录下新建脚本item2login.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"}
}
interact

这里[lindex $argv 0][lindex $argv 1][lindex $argv 2][lindex $argv 3] 分别代表着4个参数。

然后打开iTerm2Preference-Profile,
Send test at start 按照脚本 端口号 用户名 服务器地址 密码格式对应填写
然后就可以愉快的使用了
如图1:

image.png

图2:
image.png

Android+GoLang+SprintBoot探讨群:186305789(疯狂的程序员),绝影大神在等你

个人兴趣网站:zero接码平台

个人兴趣网站:猿指


Comments

comments powered by zero