github多个账户配置ssh key使用


1、命令: 
ssh-keygen  -t  rsa  -C  "[email protected]"  -f  smq_id_rsa
(可以设置密码的哦)

2、配置github
https://github.com/settings/keys

3、配置本地pc
在~/.ssh目录下添加config配置文件用于区分多个SSH-Key

vim ~/.ssh/config

Host me.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/me_rsa

Host work.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/smq_id_rsa

4、配置具体的项目
git clone git@github.com:xxxxx/xxxxx.git
(原来的URL)

git config --local user.name 你的名字(体现在提交日志中)
git config --local user.email  你的邮箱

git remote set-url origin git@work.github.com:xxxxx/xxxxx.git
(work.github.com是一个别名,你可以随便起)

git push

猜你喜欢

转载自blog.csdn.net/lsziri/article/details/77650831
今日推荐