Ungazilawula njani iiAkhawunti ezininzi zeGitHub kuMatshini omnye

Njengabaphuhlisi kufuneka sijike sijikeleze iiakhawunti ezininzi zeGitHub kumatshini omnye. Umzekelo sineakhawunti yethu yeGitHub yobuqu yeprojekthi yethu kunye nenye i-akhawunti yeGitHub esiyisebenzisela iprojekthi yethu yomthengi.

Eli nqaku libonelela ngemiyalelo yenyathelo ngenyathelo ngendlela yokuseta kunye nokusebenza neeakhawunti ezininzi zeGitHub kumatshini omnye.



Lawula iiAkhawunti ezininzi zeGitHub

Kule meko siza kwenza iiakhawunti ezimbini zeGitHub kumatshini omnye kwaye sitshintshe phakathi kwezi zimbini.


Yenza amaqhosha e-SSH

Kuqala, kufuneka senze amaqhosha ethu abucala / esidlangalaleni e-SSH yethu ngokobuqu iakhawunti.

Singakwenza oku ngokwenza lo mthetho ulandelayo kwisiphelo sendlela:


$ ssh-keygen -t rsa -C 'email@gmail.com' -f 'id_rsa_personal'

Le dilesi ye-imeyile ingentla uyisebenzisayo ukungena kwiakhawunti yakho ye-GitHub.

Xa ubuzwa ngendawo yokugcina amaqhosha, yamkela indawo emiselweyo ngokucinezela ukungena. Isitshixo sangasese / esidlangalaleni esidibeneyo senziwe kwindawo ssh emiselweyo ~/.ssh/.

Izitshixo zethu ze-SSH zobuqu zezi:

~/.ssh/id_rsa_personal.pub kunye ~/.ssh/id_rsa_personal


Emva koko, senza amaqhosha ethu abucala / esidlangalaleni e-SSH yethu umxhasi iakhawunti:

$ ssh-keygen -t rsa -C 'email@company.com' -f 'id_rsa_company'

Le dilesi ye-imeyile ingasentla yile uyisebenzisayo ukungena kwiakhawunti yakho yeGitHub.

Lo myalelo ungasentla wenza izitshixo zethu zabaxhasi beSSH kwiindawo ~/.ssh/.

Izitshixo zethu zabaxhasi beSSH zezi:


~/.ssh/id_rsa_company.pub kunye ~/.ssh/id_rsa_company

Yongeza amaqhosha e-SSH kwiiakhawunti zeGitHub

Ngena kwiakhawunti yakho ye-GitHub kwaye ungeze eyakho id_rsa_personal.pub Ukhiye woluntu.

Emva koko, ngena kwiakhawunti yakho yeGitHub kwaye ukongeze id_rsa_company.pub ukhiye woluntu.

Ukuba awuqinisekanga ukuba ungayenza njani le nto, funda faka iGit kwaye wenze iiSSH Keys .


Uhlaziyo lwefayile yoqwalaselo lweSSH

Ifayile yoqwalaselo yeSSH ihlala kwi ~/.ssh/. Ukuba awuboni ifayile yoqwalaselo, yenza enye:

$ cd ~/.ssh/ $ touch config

// Creates the file if not exists $ nano config

// Opens the file for editing

Yongeza iifayile zakho ezahlukeneyo zeGitHub kwifayile yoqwalaselo lweSSH:

# Personal account Host github.com-personal HostName github.com User git IdentityFile ~/.ssh/id_rsa_personal # Company account-1 Host github.com-company HostName github.com User git IdentityFile ~/.ssh/id_rsa_company

Bhalisa amaqhosha e-SSH nge-ssh-arhente

Qala iarhente yakho ye-ssh ngokusebenza eval '$(ssh-agent -s)'.

Emva koko yongeza izitshixo zakho ze-SSH kwi-ssh-arhente:


ssh-add ~/.ssh/id_rsa_personal ssh-add ~/.ssh/id_rsa_company

Oku kuyakubhalisa izitshixo zakho ze-SSH kunye ne-ssh-arhente kumatshini.

Inye kuphela isitshixo esisebenzayo seSSH kwiarsh-arhente ngexesha

Ngoku sizenzele izitshixo zethu ze-SSH zobuqu kunye nenkampani kwaye sizibhalise kwi-ssh-arhente, ngoku sinokutshintsha ngokulula phakathi kweeakhawunti ezimbini zeGitHub kumatshini omnye.

Kufuneka siqiniseke ukuba sinesitshixo kuphela se-SSH esongeziweyo kwi-ssh-arhente ngexesha.

Umzekelo, ukuba sisebenza kwiprojekthi yethu senza:

$ ssh-add -D

//removes all ssh entries from the ssh-agent $ ssh-add ~/.ssh/id_rsa_personal
// Adds the personal ssh key

Ngokunjalo, ukuba sisebenza kwiprojekthi yethu yomthengi, senza:

$ ssh-add -D

//removes all ssh entries from the ssh-agent $ ssh-add ~/.ssh/id_rsa_company

// Adds the company ssh key

Nantsi ke indlela esinokulawula ngayo iiakhawunti ezininzi zeGitHub kumatshini omnye kwaye sitshintshe phakathi kwabo ngelixa sisebenza kwiiprojekthi ezahlukeneyo.