Mac实现iTerm2 免登录ssh服务器

2,471 阅读1分钟

在你电脑的任意位置创建自动登录的脚本

  1. touch itermSsh.sh
  2. vim itermSsh.sh
  3. shell
#!/usr/bin/expect -f
set user _user
set host _host
set password _password
set timeout -1
spawn ssh $user@$host
expect "*assword:*"
send "$password\r"
interact
expect eof

tip:替换_user用户名, _host服务器地址, _password密码

  1. 打开iTerm的Preferences -> 切换到Profiles Tab -> new profile -> 在Command那一个输入框内写上itermSsh.sh的路径就可以。

  1. 然后new Tab的时候选择你创建的profile