背景:
使用iTerm2进行ssh登录到远程服务的时候,每次要敲命令行很麻烦
目标:
设置iTerm2会话脚本,双击进入服务器,并转入目标目录
操作:
编写脚本
//spawn插件百度下安装
#!/usr/bin/expect
set timeout 30
spawn ssh -p 22 root@服务器IP地址
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "输入你自己的密码\n"}
}
expect "*#*" {
send "cd 需要跳转的目录\r"
}
interact
- 工具配置
打开iTerm2的Profiles
配置脚本路径
实现效果