1、准备ssh-copy-id
brew install ssh-copy-id
2、生成私钥公钥
ssh-keygen -t rsa -b 1024
3、将公钥上传致服务器(~/.ssh/authorized_keys)
ssh-copy-id -i 公钥 root@192.168.1.xxx
4、在本地~/.ssh/config文件中添加(如果没有则新建)
Host git.oschina.net
IdentityFile ~/.ssh/weiwei.sun
Host 192.168.50.100
IdentityFile ~/.ssh/weiwei.sun