好久以前就要寫了,一直拖着,蹭着週末開寫git
自從公司轉用git管理代碼以後,更多的和git打交道了,之前也使用過git/github ,如今公司也推git,就有多帳戶的問題了,查了下資料,是能夠在一臺機子上配置多個帳戶的,固然是不一樣的賬戶了(github gitoschina 公司git)。github
$ ssh-keygen -t rsa -C "youremail@yourcompany.com」 -f ~/.ssh/id-rsa
-f 後面就是生成的名字及位置了,同理生成其餘的多個私鑰與公鑰bash
ssh-add ~/.ssh/id_rsa
若是提示「Could not open a connection to your authentication agent」,執行服務器
$ ssh-agent bash
而後再執行ssh-addssh
# 能夠經過 ssh-add -l 來確私鑰列表 $ ssh-add -l # 能夠經過 ssh-add -D 來清空私鑰列表 $ ssh-add -D
在.ssh目錄下新建一個config文件,配置相應的SSH-Key測試
#github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github-rsa #oschina Host git.oschina.net HostName git.oschina.net IdentityFile ~/.ssh/oschina-rsa #git.XXXX.com Host git.XXXX.com HostName git.XXXX.com RSAAuthentication yes IdentityFile ~/.ssh/id_rsa
最後目錄裏有這些文件spa
-rwxr-xr-x@ 1 sina staff 320 9 28 15:42 config -rw------- 1 sina staff 1675 2 26 2016 github-rsa -rwxr-xr-x 1 sina staff 399 2 26 2016 github-rsa.pub -rw------- 1 sina staff 1679 3 2 2016 id_rsa -rwxr-xr-x 1 sina staff 406 3 2 2016 id_rsa.pub -rw------- 1 sina staff 1679 2 26 2016 oschina-rsa -rwxr-xr-x 1 sina staff 398 2 26 2016 oschina-rsa.pub
測試ssh -T.net
$ ssh -T git@git.oschina.net Welcome to Git@OSC, LCZ777!
配合sourcetree 使用git效果更佳。code
仍是太懶了,拖着大半年瞭如今才寫,懶癌很嚴重啊blog
參看地址: