iterm2 安装
到官网下载最新版。https://www.iterm2.com/downloads.html
点击点击自动安装
编辑登陆脚本
以下是一个完成版的脚本 test.sh:
#!/usr/bin/expect // 指定shebang
set timeout 3 // 设定超时时间为3秒
spawn ssh user_name@172.***.***.*** // fork一个子进程执行ssh命令
expect "*password*" // 期待匹配到 password'
send "my_password\r" // 向命令行输入密码并回车
send "cd /data/logs\r" // 帮我切换到常用的工作目录
interact // 允许用户与命令行交互
执行 sudo chmod +x ./test.sh命令给shell脚本添加执行权限;
运行 ./test.sh命令,一键登陆成功!
编辑 iterm2 的profile
新加一个profile
general > commend > test.sh
设置标签。test
下次直接 通过 iterm中的profile。直接点击就登陆成功了