1. 快捷登录ssh
1.1 安装sshpass
为了避免每次手动输入密码,因此使用sshpass
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
如果出现如下错误:
Updating Homebrew...
Traceback (most recent call last):
'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported! (UsageError)
'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of sshpass formula file from an arbitrary URL is unsupported! (UsageError)
则换一种方式安装: 新建 ~/temp/sshpass.rb文件,内容如下
require 'formula'
class Sshpass < Formula
url 'http://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz'
homepage 'http://sourceforge.net/projects/sshpass'
sha256 'c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
def test
system "sshpass"
end
end
再执行brew安装:
brew install ~/temp/sshpass.rb
1.2 配置iterm2
配置profile:
#sshpass -p [密码] ssh -o StrictHostKeyChecking=no -p [端口] [用户名]@[ip地址]
sshpass -p 123456 ssh -o StrictHostKeyChecking=no -p 22 root@192.168.223.137
ok,这样就可以直接使用profiles通过ssh登录到远程主机了。
2. 支持rzsz
2.1 安装rzsz
mac 安装:
brew install lrzsz
远程主机也要安装rzsz
#比如centos通过yum安装
yum -y install lrzsz
2.2 安装iterm2-zmodem
详见:https://github.com/laggardkernel/iterm2-zmodem
brew install laggardkernel/tap/iterm2-zmodem
安装完后会出现如下提示内容提示:
Create triggers under Profiles -> Advanced:
Regular expression: rz waiting to receive.**B0100
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-zmodem-send
Instant: checked
Regular expression: **B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-zmodem-recv
Instant: checked
根据这个内容添加iterm2的两个triggers配置:
注意*号前面要加“\”转义,否则执行会失败
测试
通过iterm2的profile登录到远程机器后进行测试:
# 执行sz: sz [要发送的文件名]
sz test.txt
# 执行后,会弹出访达窗口选择要保存的路径
# 执行rz,接收文件
rz
# 执行后,会弹出访达窗口选择要接收的文件