2개 이상의 GitHub 저장소에 대한 SSH Key 관리 및 Git 원격 저장소 설정 방법
1. SSH Key 생성
- 키 파일 생성
# ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-keygen -t ed25519 -C "sh1517.you@gmail.com"
- 키 파일 배치할 경로 입력
> Enter file in which to save the key (/c/Users/YOU/.ssh/id_ALGORITHM):[Press enter]
- Passphrase 입력
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
2. GitHub 계정에 새 Key 파일 추가
- GitHub → Settings → SSH and GPG Keys → New SSH Key 버튼 클릭
- /C/Users/YOUR_USER_NAME/.ssh/id_ALGORITHM.pub 파일 내용 복사 및 붙여넣기
3. Git 원격 저장소 설정 (SSH URL)
기본 SSH 주소 값에 Alias 값을 추가해서 복수의 GitHub 저장소를 구분할 수 있도록 구성
git@github[HOST_ALIAS]:[USER_NAME]/[REPOSITORY_NAME].git
- A 프로젝트 Remote 저장소 SSH URL 등록
git remote set-url origin git@github-a:alice/repository.git
- B 프로젝트 Remote 저장소 SSH URL 등록
git remote set-url origin git@github-b:bob/repository.git
4. SSH Config 파일 설정
# ~/.ssh/config
Host github.com-a
HostName github.com
User alice
IdentityFile ~/.ssh/a
Host github.com-b
HostName github.com
User bob
IdentityFile ~/.ssh/b
'CICD > Git' 카테고리의 다른 글
[Git] Branch 전략 (0) | 2025.04.09 |
---|---|
[Git] Git reset / revert (0) | 2025.04.08 |
[Git] Merge 전략 (0) | 2025.04.08 |
[Git] Command 정리 (0) | 2025.04.08 |
[Git] Git 기본 개요 (0) | 2025.04.08 |