iterm2 配置远程连接免登陆

1、编写txt文本文件

#!/usr/bin/expect -f
set user 用户名
set port 端口
set host url
set password 密码
set timeout -1

spawn ssh $user@$host -p $port
expect {
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "$password\r"}
}
interact
expect eof

客户端配置
Profiles=>选择Command
内容填入:expect 绝对路径.txt
2、编写.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"}
}
expect "~"
send "clear\n"
interact

客户端配置
profiles=》选择login shell
绝对路径.sh 端口 用户名 url 密码

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容