Mac系统下,让Iterm 4 来记住常用的登录账号和密码
2023-09-27 14:28:39 时间
文章转自 https://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个参数。
然后打开iTerm2
的Preference
-Profile
,
Send test at start
按照脚本 端口号 用户名 服务器地址 密码
格式对应填写
然后就可以愉快的使用了
如图1:
![](http://upload-images.jianshu.io/upload_images/4338948-94d4896813dee500.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
图2:
![](http://upload-images.jianshu.io/upload_images/4338948-adc894ab8b91c1ce.png?imageMogr2/auto-orient/strip|imageView2/2/w/956/format/webp)
image.png
然后再profile 里可以选择不同的服务器
其它items 配置,参考文档
https://www.yuque.com/wangdd/blog/ba84a7
https://www.yuque.com/wangdd/blog/gon16g