1、生成github的ssh keyhtml
ssh-keygengit
ssh-keygen -t rsa -f ~/.ssh/zzf073_rsa -C zzf073@163.comgithub
2、配置帳戶公鑰ssh
一、查看拷貝公鑰測試
pbcopy < ~/.ssh/id_rsa.pubdebug
cathtm
二、配置ssh keysblog
3、github鏈接測試it
ssh -T git@github.comio
ssh -v git@github.com
4、密鑰名稱配置(多帳戶配置)
問題: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
5、其它命令
第一步,git config --global --list 驗證郵箱
第二步,git config --global user.name "yourname",git config --global user.email myemail@qq.com 設置全局用戶名和郵箱,
第三步,ssh-keygen -t rsa -C "這裏換上你的郵箱",生成祕鑰,
第四步,到git倉庫,添加祕鑰,
第五部,ssh -T git@github.com 測試一下通不通,不通就是ssh-agent -s ssh-add ~/.ssh/id_rsa 操做這兩步
最後clone,藥到病除!!!
參考文獻:
Mac配置多個git ssh key:
https://www.jianshu.com/p/5fc66d18017d
git@github.com: Permission denied (publickey).
https://www.cnblogs.com/jenkin1991/p/9604054.html