windows同一臺電腦設置多個公鑰與不一樣github賬號交互

1 生成公鑰git

1. 安裝git,從C:\Documents and Settings\Administrator\.ssh\目錄打開 "Git Bash";
2. 鍵入命令:ssh-keygen -t rsa -C "email@email.com","email@email.com"是github帳號;
3. 提醒你輸入key的名稱,輸入如id_rsa_githubName;
4. 在C:\Documents and Settings\Administrator\下產生兩個文件:id_rsa_githubName和id_rsa_githubName.pub;github

 

2 添加公鑰到某個github帳號ssh

用記事本打開id_rsa.pub文件,複製內容,在github.com的網站上到ssh密鑰管理頁面,添加新公鑰,隨便取個名字,內容粘貼剛纔複製的內容;網站

 

3 在C:\Documents and Settings\Administrator\.ssh\目錄配置文件configci

#personal account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsait

#work account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_githubNameemail

 

4 用ssh訪問github配置

git clone git@github.com-work:socialchorus/repo_name.gitrsa

相關文章
相關標籤/搜索