git多账号配置

多git账号配置

  1. 针对多个git分别生成公私秘钥
    • ssh-keygen -t rsa -C aa@git.com
    • ssh-keygen -t rsa -C bb@git.com
  2. 将上述生成的公钥拷贝到对应git地址内的ssh key
  3. vim ~/.ssh/config
    Host github.com
        HostName github.com
        User aa
        IdentityFile /home/xxx/.ssh/aa_id_rsa
    Host gitlab.com
        HostName git.xxx.com
        User bb
        IdentityFile /home/xxx/.ssh/bb_id_rsa
    
  4. 问题
    • 免密不生效
      • 目录权限 .ssh 700; .ssh/config 600
      • git设置: git config --global credential.helper store
        • 备注:不安全操作,用户和密码信息会明文保存到本地
        • The .git-credentials file is stored in plaintext. Each credential is stored on its own line as a URL like:https://user:pass@example.com

posted @ 2021-09-17 15:04  春树&暮云  阅读(137)  评论(0编辑  收藏  举报