1、打开命令行窗口Terminal$ ssh-keygen -t rsa -b 4096 -C "[email protected]"此时在用户目录下生成ssh公钥及对应密钥~/.ssh/id_rsa 及~/.ssh/id_rsa.pub
2、如果mac系统是10.12.2及以上,需要更改~/.ssh/config文件配置Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa
3、添加本地生成的ssh私钥到ssh-agentssh-add -K 本地私钥路径地址
4、在你需要clone的系统中,添加用户的ssh公钥pbcopy < ~/.ssh/id_rsa.pub复制公钥内容到剪切板中。