iterm2保存服务器账号密码

1.进入:

~/.ssh/test            // test无后缀名

2.编辑内容

# 编辑汉字部分
set user 用户名
set host 主机IP
set password 密码

spawn ssh $user@$host
expect "*assword:*"
send "$password\r"
interact
expect eof

3.添加配置

![image-20210609133532449](/Users/liuwenlong/Library/Application Support/typora-user-images/image-20210609133532449.png)

第一步:点击profiles => open profiles 打开profiles

第二步:点击profiles面板中的edit profiles

第三步:点击preferences面板中左侧下方的加号,添加一项

第四步:在command中添加expect ~/.ssh/test

4.重启iterm2

5.再次打开iterm2, 使用快捷键command+o打开profiles面板,点击配置名连接服务器

报错:A session ended very soon after starting. Check that the command in profile "New Profile" is correct.

![image-20210609134154605](/Users/liuwenlong/Library/Application Support/typora-user-images/image-20210609134154605.png)

解决:删除~/.ssh/known_hosts中对应的ip,重新连接,成功!

posted @ 2021-06-10 17:45  刘先森的博客  阅读(736)  评论(0)    收藏  举报