mac下使用iterm实现自动登陆
阅读原文时间:2023年07月08日阅读:1

1、通过brew安装sshpass(手动安装也可以)

①brew安装sshpass

brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb

或者

brew install http://git.io/sshpass.rb
②验证是否安装成功,输入以下命令

sshpass -h
 输出结果

Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin

-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
sshpass远程登录命令为:

/usr/local/bin/sshpass -p 密码 ssh -p端口 用户名@IP
-p 可以直接输入密码

-f 可以读取文件中的密码

每个密码单独存个文件太麻烦了,我们使用-p的方式。

2、在iterm2中使用sshpass记住密码

①打开iterm2

②打开设置

iTerm2  command+,>> Profiles >> Open Profiles >> Edit Profiles

按照一下步骤选择Command方式添加上我们的sshpass命令(截图中命令使用了/usr/local/bin/sshpass,我没有配path所以要使用绝对路径)

③使用

(注意:如果第一次使用sshpass链接失败,需要先使用一下ssh命令连接一次,输入命令   ssh -p端口 用户名@IP 按提示输入密码,链接一次之后在使用我们的配置链接就OK了)

以下方式就可以打开我们配置好的远程服务器窗口

————————————————
版权声明:本文为CSDN博主「grootblockchain」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/CaptainJava/article/details/84316773

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章