git多账号配置
多git账号配置
- 针对多个git分别生成公私秘钥
- ssh-keygen -t rsa -C aa@git.com
- ssh-keygen -t rsa -C bb@git.com
- 将上述生成的公钥拷贝到对应git地址内的ssh key
- 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
- 问题
- 免密不生效
- 目录权限 .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
- 免密不生效