Mac iTerm2 自动登录配置

方法一、使用sshpass命令

安装sshpass

sudo brew install http://git.io/sshpass.rb

配置iTerm2

Preference>profiles 快捷键 command+,
新建demo profile
配置command

/usr/local/bin/sshpass -p passwrod  ssh userName@ip -o StrictHostKeyChecking=no
image.png

方法二、使用expect,spawn (窗体调整后可能引起显示异常问题),不推荐使用

新建脚本item2login.sh

#!/usr/bin/expect

set timeout 30  
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]  
expect {  
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "[lindex $argv 3]\n"}
}
interact

配置iTerm2

Preference>profiles 快捷键 command+,
新建demo2 profile
配置command

/Users/admin/sh/item2login.sh 22 userName IP password
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容