一台电脑同时配置github私人账户和公司账户
2017-12-29 17:23
330 查看
参考:
https://www.cnblogs.com/xjnotxj/p/5845574.html http://blog.csdn.net/birdben/article/details/51824788 https://help.github.com/articles/error-permission-denied-publickey/
######################################
1. 两个账户分别生成ssh key
cd ~/.ssh
这个文件我叫它: id_rsa_self, 同时会生成一个id_rsa_self.pub
这个文件我叫它: id_rsa_company, 同时会生成一个id_rsa_company.pub
2. 添加私钥
3. 分别登录私人和公司的github,配置ssh-key
将 id_rsa_xxx.pub的内容贴进去
4. 配置 config
cd ~/.ssh
# self(2453929471@qq.com)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_self
User 2453929471
# company(mgao@company.com)
Host github.company.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_company
User mgao
5. 测试
➜ .ssh ssh -T git@github.company.com
Hi mgao! You've successfully authenticated, but GitHub does not provide shell access.
➜ .ssh ssh -T git@github.com
Hi 2453929471! You've successfully authenticated, but GitHub does not provide shell access.
注意,我当时这里犯了一个错误,就是我用的 mgao@github.company.com去登录的,然后报publickey的错误。
官方文档写的很清楚
All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:
If your connection failed and you're using a remote URL with your GitHub username, you can change
the remote URL to use the "git" user.
You should verify your connection by typing:
https://www.cnblogs.com/xjnotxj/p/5845574.html http://blog.csdn.net/birdben/article/details/51824788 https://help.github.com/articles/error-permission-denied-publickey/
######################################
1. 两个账户分别生成ssh key
cd ~/.ssh
ssh-keygen -t rsa -C "2453929471@qq.com"
这个文件我叫它: id_rsa_self, 同时会生成一个id_rsa_self.pub
ssh-keygen -t rsa -C "mgao@company.com"
这个文件我叫它: id_rsa_company, 同时会生成一个id_rsa_company.pub
2. 添加私钥
ssh-agent -s
ssh-add ~/.ssh/id_rsa_self
ssh-add ~/.ssh/id_rsa_company
3. 分别登录私人和公司的github,配置ssh-key
将 id_rsa_xxx.pub的内容贴进去
4. 配置 config
cd ~/.ssh
touch config
# self(2453929471@qq.com)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_self
User 2453929471
# company(mgao@company.com)
Host github.company.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_company
User mgao
5. 测试
➜ .ssh ssh -T git@github.company.com
Hi mgao! You've successfully authenticated, but GitHub does not provide shell access.
➜ .ssh ssh -T git@github.com
Hi 2453929471! You've successfully authenticated, but GitHub does not provide shell access.
注意,我当时这里犯了一个错误,就是我用的 mgao@github.company.com去登录的,然后报publickey的错误。
官方文档写的很清楚
Always use the "git" user
All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:ssh -T GITHUB-USERNAME@github.com Permission denied (publickey).
If your connection failed and you're using a remote URL with your GitHub username, you can change
the remote URL to use the "git" user.
You should verify your connection by typing:
ssh -T git@github.com Hi username! You've successfully authenticated...
相关文章推荐
- 同一台电脑需要同时配置github和gitlab
- 一台电脑上同时使用两个github账户
- 一台电脑上的git同时使用两个github账户
- 一台电脑上的git同时使用两个github账户
- [转]一台电脑上的git同时使用两个github账户
- 一台电脑同时运行多个tomcat配置方法
- 一台电脑同时配置多个Tomcat容器
- 一台电脑同时配置2个tomcat
- 一台电脑同时运行多个tomcat配置方法
- 一台电脑同时运行多个tomcat配置方法
- 如何在同一台电脑上使用两个github账户
- 一台电脑同时运行多个tomcat配置方法
- 如何在同一台电脑上多个账户同时登陆MSN
- 一台电脑同时运行多个tomcat配置方法
- 一台电脑同时运行多个tomcat配置方法
- 手把手叫你一台电脑配置两个Git账户
- Git 多账户配置使用,同时使用github 和 gitoschina
- 一台电脑同时运行多个tomcat配置方法 (转)
- 如何在同一台电脑上使用两个github账户
- 一台电脑同时运行多个tomcat配置方法