여러 Github 계정 관리
This guide is intended for Unix users.
SSH 키 설정
로컬 워크스테이션에서 새 SSH 키를 생성할 수 있습니다. 키를 생성한 후 Git 활동에 대한 SSH 인증을 허용하도록 GitHub 계정에 키를 추가할 수 있습니다.
Note: On March 15, 2022, GitHub increased security by removing obsolete, unsafe key types.
DSA keys (ssh-dss) are no longer supported as of that date. You cannot add additional DSA keys to your own GitHub account.
RSA keys (ssh-rsa) with a valid_after date prior to November 2, 2021 may continue to employ any signature algorithm. After that date, RSA keys must be produced using the SHA-2 signature technique. Some older clients may require an upgrade to utilise SHA-2 signatures.
두 개의 Github 계정 이름이 githubPersonal 및 githubWork라고 가정합니다.
두 개의 SSH 키를 생성하고 서로 다른 파일에 저장합니다.
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "[email protected]"
# save it as id_rsa_personal when prompted
$ ssh-keygen -t rsa -C "[email protected]"
# save it as id_rsa_work when prompted
위의 명령으로 다음 파일이 생성됩니다.
id_rsa_personal
id_rsa_personal.pub
id_rsa_work
id_rsa_work.pub
GitHub 개인 계정에 새 SSH 키 추가
SSH 공개 키를 클립보드에 복사합니다.
If your SSH public key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don’t add any newlines or whitespace.
$ pbcopy < ~/.ssh/id_rsa_personal.pub
# Copies the contents of the id_rsa_personal.pub file to your clipboard
Tip: If
pbcopyisn't working, you can locate the hidden.sshfolder, open the file in your favorite text editor, and copy it to your clipboard.
계정에 키를 추가합니다.
GitHub 작업 계정에 대해 프로세스를 반복합니다.
ssh-agent에 SSH 키 추가
macOS Sierra 10.12.2 이상을 사용하는 경우 키를 ssh-agent에 자동으로 로드하고 키체인에 암호를 저장하도록 파일
~/.ssh/config을 수정해야 합니다.~/.ssh/config 파일이 기본 위치에 있는지 확인하십시오.$ open ~/.ssh/config
> The file /Users/you/.ssh/config does not exist.
$ touch ~/.ssh/config ~/.ssh/config 파일을 연 다음 다음 줄을 포함하도록 파일을 수정합니다. SSH 키 파일의 이름이나 경로가 예제 코드와 다른 경우 설정과 일치하도록 파일 이름이나 경로를 변경합니다.# githubPersonal
Host personal
HostName github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa_personal
# githubWork
Host work
HostName github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa_work
저장된 ID 업데이트
현재 저장된 ID 지우기:
$ ssh-add -D새 키 추가:
$ ssh-add -K ~/.ssh/id_rsa_personal
$ ssh-add -K ~/.ssh/id_rsa_work
새 키가 저장되었는지 테스트합니다.
$ ssh-add -lGithub가 키를 인식하는지 테스트합니다.$ ssh -T personal
Hi githubPersonal! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh -T work
Hi githubWork! You've successfully authenticated, but GitHub does not provide shell access.
기본 계정을 전역으로 설정
git config --global user.name "personal"
git config --global user.email "[email protected]"
푸시 테스트
Github의 개인 계정에 "test-personal"이라는 새 리포지토리를 만듭니다.
로컬 컴퓨터로 돌아가서 테스트 디렉터리를 만듭니다.
$ cd ~/documents
$ mkdir test-personal
$ cd test-personal
빈
readme.md 파일을 Github에 추가하고 다음을 푸시합니다.$ touch readme.md
$ git init
$ git add .
$ git commit -am "first commit"
$ git remote add origin git@personal:githubPersonal/test-personal.git
$ git push origin master
Notice how we’re using the custom account,
git@personal, instead of[email protected].
githubWork 계정에 대해 프로세스를 반복합니다.
풀 테스트
Github의 개인 계정에 있는
readme.md 파일에 텍스트를 추가합니다.이제 test-personal 디렉터리 내에서 다음 명령을 실행하여 변경 사항을 가져오고 병합합니다.
$ git pull origin master
다시 githubWork 계정에 대해 이것을 반복하십시오.
저장소 복제
$ git clone git@personal:githubPersonal/test-personal.git
# For personal repository
$ git clone git@work:githubWork/test-personal.git
# For Work repository
기본이 아닌(githubWork) 계정을 사용하는 경우 프로젝트 폴더에 로컬 구성을 추가해야 합니다.
$ git clone git@work:githubWork/test-personal.git
$ git config user.name "work"
$ git config user.email "[email protected]"
Reference
이 문제에 관하여(여러 Github 계정 관리), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/itismowgli/managing-multiple-github-accounts-2m54텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)