mac篇---使用iTerm2快捷链接SSH

你们都知道使用iTerm2链接shh 使用命令 ssh -p22 root@129.10.10.1,而后输入密码便可。shell

可是每次都输入仍是比较麻烦的。iTerm2为咱们提供了快捷的方式。三步便可完成此项设置。方法以下:bash

1,编辑命令文本网络

样本:ssh

输入:~/.ssh/ 而后回车工具

新建一个shell文件,命名为iterm2login.sh,里面写入内容:ui

#!/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

 注:要记得给sh文件赋予权限  chmod 777 iterm2login.shspa

语法说明:shell文件是expect语言脚本,能够自动和网络交互,基本原理就是解析ssh的命令文本返回,根据文本内容匹配,执行对应的操做,send就是模拟人工输入。code

 

2,设置调用命令blog

第二步: 设置iterm2,在profiles中创建一个新profile,配置如192.168.100.127中描述ip

 

 

Name: 填写便于记忆的名称
Login shell -> Send text at start: /Users/yuml/bin/iterm2login.sh 22 root 192.168.100.127 password

 

第三步: 运行profile, 在iterm2的顶部工具栏有一栏Profiles,就能够看到对应的profle,双击就能够了

 

4.ssh登陆 The authenticity of host 192.168.0.xxx can't be established. 的问题

 

用ssh登陆一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束

错误是:The authenticity of host 192.168.0.xxx can't be established.

执行ssh  -o StrictHostKeyChecking=no  192.168.0.xxx 就OK

相关文章
相关标签/搜索