1.生成兩個不同的ssh
ssh-keygen -t rsa -c "yourmail@gmail.com"
生成金鑰步驟
執行兩次,設定不同的名字或路徑。
2.配置
將公鑰*.pub加入**託管平台的配置中,如github
當前使用者目錄中建立config檔案
3.測試# 該檔案用於配置私鑰對應的伺服器
# default github user(yusitong1999@foxmail.com)
host github.com
hostname github.com
user git
identityfile c:\users\yusitong\.ssh\yst_rsa
#gitee (僅為示例,實際上一對金鑰只能用在一處)
host gitee.com
hostname gitee.com
user git
identityfile c:\users\yusitong\.ssh\yst_rsa
# second user(supplydemand_whu@163.com)
# 建乙個github別名,新建的帳號使用這個別名做轉殖和更新
host github2
hostname github.com
user git
identityfile c:\users\yusitong\.ssh\id_rsa
測試效果ssh -t git@github.com
ssh -t git@gitee.com
ssh -t git@github2
4.使用
使用時將預設提供的位址中的hostname改為host
如:
# 以host為github.com對應的身份
git@github.com:supplydemandwhu/whusupplydemand.git
# 改為 以host為github2對應的身份
git@github2:supplydemandwhu/whusupplydemand.git
Git 與 ssh key 多賬戶配置 md
終端下 cd 到 ssh 目錄下,執行 ssh keygen t rsa c biao166 github.com f id rsa github其中 biao166 github.com 替換為你的郵箱,id rsa github 為生成檔案檔名,執行後會問你是否需要 enter a passph...
Git配置多個SSH Key
之前週末在家使用github建立ssh key進行blog的提交,但是第二天在用公司,使用公司的gitlab提交 時發現賬號是我github的賬號,我想肯定是github生成的ssh key把之前我公司gitlab的ssh key給覆蓋了 檢視我所有ssh key cd ssh ls github ...
git 配置多個SSH Key
專案託管的倉庫多了,使用的賬號多了,自然用到的key就不同了,比如gitlab,bitbucket,github,公司的code倉庫等,所以管理好key很重要。1,生成乙個公司用的ssh key ssh keygen t rsa c 1email company.com f ssh id rsa2,...