一、生成github的ssh key
ssh-keygen -t rsa -f ~/.ssh/zzf073_rsa -C [email protected]
二、配置账户公钥
1、查看拷贝公钥
pbcopy < ~/.ssh/id_rsa.pub
cat
2、配置ssh keys
三、github连接测试
ssh -T [email protected]
ssh -v [email protected]
四、密钥名称配置(多账户配置)
问题:git连接建立时会按照缺省密钥查找本地路径:
debug1: Trying private key: /Users/zzf073/.ssh/id_rsa
debug1: Trying private key: /Users/zzf073/.ssh/id_dsa
debug1: Trying private key: /Users/zzf073/.ssh/id_ecdsa
debug1: Trying private key: /Users/zzf073/.ssh/id_ed25519
Host github.com
IdentityFile ~/.ssh/zzf073_rsa
User git
五、其它命令
第一步,git config --global --list 验证邮箱
第二步,git config --global user.name "yourname",git config --global user.email [email protected] 设置全局用户名和邮箱,
第三步,ssh-keygen -t rsa -C "这里换上你的邮箱",生成秘钥,
第四步,到git仓库,添加秘钥,
第五部,ssh -T [email protected] 测试一下通不通,不通就是ssh-agent -s ssh-add ~/.ssh/id_rsa 操作这两步
最后clone,药到病除!!!
参考文献:
Mac配置多个git ssh key:
https://www.jianshu.com/p/5fc66d18017d
[email protected]: Permission denied (publickey).
https://www.cnblogs.com/jenkin1991/p/9604054.html