1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| # 生成公钥 $ ssh-keygen -t rsa -C "<your email>" $ ssh-keygen -t rsa -C "<your another email>"
# 配置 config $ vim ~/.ssh/config Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa
Host github.com-work HostName github.com User git IdentityFile ~/.ssh/id_rsa_work # 指定账号添加对应公钥 # 使用, 克隆或添加remote时使用config定义的Host别名(github.com / github.com-work / 其他) $ git clone git@github.com:<user-name>/<repo-name>.git $ git remote add origin git@github.com:<user-name>/<repo-name>.git
|