多個git使用的 ssh key共存


  • ssh-keygen -t rsa -C "ljkj028@qq.com"

不要一直回車,指定密鑰為 id_rsa_ljkj 默認為(id_rsa) 同理 創建其他密鑰

  • 打開ssh-agent

這里如果你用的github官方的bash,ssh-agent -s,
如果是其他的,比如msysgit,eval $(ssh-agent -s)

  • 添加私鑰

ssh-add ~/.ssh/id_rsa_ljkj
ssh-add ~/.ssh/id_rsa_github

  • 創建 touch config 或修改vi config文件為如下格式

Host git.ling-ju.tech
HostName git.ling-ju.tech
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User ljkj

Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User ling-ju

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM