mac 利用iTerm2 实现SSH自动登录

1、首先安装iTerm2 工具

下载地址  http://www.iterm2.com/

2、编写脚本 保存到 ~/ssh/test.sh

#!/usr/bin/expect  

set timeout 30  
spawn  ssh -p
21your name@127.0.0.1
expect {  
        "(yes/no)?"  
        {send "yes\n";exp_continue}  
        "password:"  
        {send "
your password\n"}  
}  
interact 

3、打开iTerm2工具 运行 expect test.sh 即可



版权声明:本文为wesaylove原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。