일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- IntelliJ
- mybatis
- testAnnotationProcessor
- 어플리케이션컨텍스트
- Spring
- Lombok
- Thread-safe
- AOP
- 스프링
- 그래이들
- Bean Scope
- 빌더패턴
- DataSet
- 빈 스코프
- 어플리케이션 컨텍스트
- 그래들
- WebApplicationType
- RequestMapping
- okhttp
- Java
- Gradle
- ConcurrentHashMap
- 토비
- JavaScript
- spring boot
- ApplicationContext
- 트랜잭션
- java8
- DispatcherServlet
- annotationProcessor
Archives
- Today
- Total
나만보는페이지
git SSH 설정 분리 본문
목표
- 회사 Git 서버는 사내 인증 방식 (예: SSH, Personal Access Token)
- GitHub는 자신의 GitHub 계정 인증 (권장: SSH 키)
두 쪽을 분리해서 인증하고, Git이 자동으로 도메인별로 구분해서 인증하도록 설정하면 됩니다.
SSH 키 생성 및 설정
SSH 키 생성 (GitHub용, Enterprise용)
# GitHub용 키 ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_github -C "your_github_email@example.com" # 회사 Git용 키 ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_enterprise -C "your_company_email@example.com"
~/.ssh/config 설정 (도메인별로 키 분리)
# GitHub 설정 Host github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519_github IdentitiesOnly yes # Enterprise Git 설정 (예: git.company.com) Host git.company.com HostName git.company.com User git IdentityFile ~/.ssh/id_ed25519_enterprise IdentitiesOnly yes
Host는 실제로 git clone 할 때 사용하는 주소와 같아야 합니다
예: git@github.com:yourname/repo.git, git@git.company.com:team/repo.git공개키 등록
github.com - profile - settings - SSH and GPG keys - 공개키 등록cat ~/.ssh/id_ed25519_github.pub
github 말고 회사 git 에도 비슷한 방식으로 공개키 등록
테스트
ssh -T git@github.com # GitHub 접속 확인 ssh -T git@git.company.com # Enterprise Git 접속 확인
동작 원리
비밀번호를 주고받는 게 아니라 키로 서명을 주고받는 방식
- git push 실행 → GitHub는 "너 누구냐?"
- Git 클라이언트는 ~/.ssh/id_ed25519(비공개 키)를 사용해 "전자서명"을 만듦
- GitHub는 미리 등록된 공개 키(.pub)로 그 서명이 진짜인지 검증함
- 인증 성공 → git push 실행됨
SSH vs PAT 비교
항목 | SSH 방식 | PAT (HTTPS) 방식 |
---|---|---|
연결 방식 | ssh://git@github.com | https://github.com |
인증 방식 | 공개키/비공개키 서명 | 사용자명 + 토큰 |
설정 난이도 | 약간 복잡 (키 생성 + 등록 + config) | 쉬움 (토큰 발급만 하면 됨) |
보안성 | 매우 높음 (키만 있으면 로그인됨) | 높음 (단, 평문 저장은 위험) |
여러 계정 분리 | SSH config로 쉽게 가능 | HTTPS는 계정/도메인 섞이면 복잡 |
회사 환경 | SSH 추천 | 사내 방화벽 뚫기 쉬움 (HTTPS) |
Comments