Mac下使用iTerm2自动ssh登陆服务器

使用iTerm2自动登陆通道机

一、cd ~/.sshshell

    在.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

    

二、打开iterm2  ssh

     选择iTerm2-->Prederences...spa

    

三、选择Profiles  code

     建议除Default外,新建Profile name ,而后在新建的profile  Command模块上选择 command: 填入本身在第一步中建立的shellblog

     将这个命令中的绿色部分shell 替换为第一步中本身建立的文件名ip

expect ~/.ssh/shell

  

 

四、ok  完成了; 若是有多个通道机 就建多个吧it

五、以后使用的时候,直接Profiles- ->选择本身建立的profile就能够啦class

相关文章
相关标签/搜索