mac的一些经验

2014年8月15日 | 分类: 操作系统 | 标签:

1.包安装和管理

brew是mac下的包管理工具,类似yum,apt-get等工具。
比安装wget命令是:

brew install wget

卸载:

brew uninstall wget

具体参见brew的官网:http://brew.sh/

2.ssh免密码登录服务器

mac上创建本地的密钥对:

ssh-keygen -t rsa

会在 ~/.ssh/下面生成id_rsa和id_rsa.pub,其中id_rsa.pub是需要部署到远程服务器上的,可以使用ssh-copy-id进行分发:

brew install ssh-copy-id
ssh-copy-id user@hostname

对应远程服务器的用户和主机名,输入密码后,id_rsa.pub就copy到远程的~/.ssh/的authorized_keys中
此后,再登录远程的时候就不需要输入密码了

ssh user@hostname

3.远程服务器文件下载和上传

以前在windowns下用sercueCRT的时候,从远端服务器下载文件和上传文件,可以简单的使用sz,rz命令,其实iterm2也能支持rzsz命令,具体步骤是:

安装lrzsz:

brew install lrzs

安装脚本到mac指定目录,地址在:https://github.com/mmastrac/iterm2-zmodem
Save the iterm2-send-zmodem.sh and iterm2-recv-zmodem.sh scripts in /usr/local/bin/
这一步需要注意的是:
a.脚本的可执行权限
b.脚本里面的sz/rz的路径设置正确

然后利用iterm2的triggers功能,当iterm2探测到指定的正则匹配后,自动执行后来的命令,在triggers里面配置两个规则:
Regular expression: \*\*B0100
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-send-zmodem.sh

Regular expression: \*\*B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

使用方法:

To send a file to a remote machine:

Type “rz” on the remote machine
Select the file(s) on the local machine to send
Wait for the coprocess indicator to disappear

The receive a file from a remote machine

Type “sz filename1 filename2 … filenameN” on the remote machine
Select the folder to receive to on the local machine
Wait for the coprocess indicator to disappear

本文的评论功能被关闭了.