单机上多git平台多账户配置
#--------------------------------------代碼托管平臺注冊的郵箱------------------------------------------------------
代碼托管平臺:
github.com/appleyuchi
appleyuchi@163.com
gitee.com/appleyuchi
appleyuchi@163.com
yuchi.coding.net
753743312@qq.com
#--------------------------------------制造公鑰和私鑰的命令匯總--------------------------------------------------------
命令中的郵箱要與上面的一致
$ ssh-keygen -t rsa -C "appleyuchi@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/appleyuchi/.ssh/id_rsa): id_rsa_github
生成公鑰和私鑰
$ ssh-keygen -t rsa -C "appleyuchi@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/appleyuchi/.ssh/id_rsa): id_rsa_gitee
生成公鑰和私鑰
$ ssh-keygen -t rsa -C "753743312.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/appleyuchi/.ssh/id_rsa): id_rsa_coding
生成公鑰和私鑰
然后:
$ ssh-add ~/.ssh/id_rsa_github
$ ssh-add ~/.ssh/id_rsa_gitee
$ ssh-add ~/.ssh/id_rsa_coding
?
#----------------------------------------------------------------------------------------------
分別在各大git平臺導入上述生成的公鑰.pub文件.
#----------------------------------------------------------------------------------------------
touch ~/.ssh/config
config文件中拷貝下面的內(nèi)容
Host github.comUser appleyuchiHostname github.comIdentityFile ~/.ssh/id_rsa_githubHost gitee.comUser appleyuchiHostname gitee.comIdentityFile ~/.ssh/id_rsa_giteeHost codingHostname e.coding.netUser yuchiIdentityFile ~/.ssh/id_rsa_coding#--------------------------------------測試--------------------------------------------------------
$ ssh -T git@github.com
Hi appleyuchi! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh -T git@gitee.com
Hi appleyuchi! You've successfully authenticated, but GITEE.COM does not provide shell access.
$ ssh -T git@coding
Coding 提示: Hello 大森林, You've connected to Coding.net via SSH. This is a personal key.
大森林,你好,你已經(jīng)通過 SSH 協(xié)議認證 Coding.net 服務(wù),這是一個個人公鑰
?
#-------------------------------最終文件樹:---------------------------------------------
$ cd .ssh
$ tree
.
├── config
├── id_rsa_coding
├── id_rsa_coding.pub
├── id_rsa_gitee
├── id_rsa_gitee.pub
├── id_rsa_github
├── id_rsa_github.pub
└── known_hosts
?
#-------------------------------最終效果:---------------------------------------------
各大平臺git push的時候都不再需要輸入用戶名和密碼.
但是git clone的時候giee和coding平臺依然需要輸入用戶名和密碼
總結(jié)
以上是生活随笔為你收集整理的单机上多git平台多账户配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UT890D的二极管档的使用
- 下一篇: mysql的1045 28000 排查方