Mac下使用iTerm2自动ssh登录服务器
使用iTerm2自动登录通道机
1、cd ~/.ssh
在.ssh下创建文件"shell" (其中绿色部分 替换为自己的用户名、服务器ip、密码)
#!/usr/bin/expect -f 2 set user <用户名> 3 set host <服务器ip> 4 set password <登录服务器的密码> 5 set timeout -1 6 7 spawn ssh $user@$host 8 expect "*assword:*" 9 send "$password\r" 10 interact 11 expect eof
2、打开iterm2
选择iTerm2-->Prederences...
3、选择Profiles
建议除Default外,新建Profile name ,然后在新建的profile Command模块上选择 command: 填入自己在第一步中创建的shell
将这个命令中的绿色部分shell 替换为第一步中自己创建的文件名
expect ~/.ssh/shell
4、ok 完成了; 如果有多个通道机 就建多个吧
5、之后使用的时候,直接Profiles- ->选择自己创建的profile就可以啦