반응형
서론
개발 작업 시 Github를 형상 관리 도구로 사용하고 있다.
개인 작업, 회사, 외주 등 관리하는 계정이 많아질 수 있는데,
각 계정별 SSH Key를 관리하여 작업 디렉토리마다 키 분리 전략을 수립하고 설정해본다.
SSH Key 생성
% ssh-keygen -t ed25519 -C "{사용 이메일}" -f ~/.ssh/{관리 SSH Key명}
Enter passphrase for "" (empty for no passphrase): # 엔터, 패스워드 없음
Enter same passphrase again: # 엔터, 패스워드 없음
Your identification has been saved in /Users/gimbeomseog/.ssh/id_ed25519_ssg02138
Your public key has been saved in /Users/gimbeomseog/.ssh/id_ed25519_ssg02138.pub
The key fingerprint is:
SHA256:~~~
The key's randomart image is:
+--[ED25519 256]--+
| .~~~~~ |
| + .o + |
| + B . |
| ~~~~~~= * |
|o.~~~~~~~ |
|=+.+B+ |
|*=~~~~~~~~~~~~ |
|++o~~~~~ |
|o~~~. |
+----[SHA256]-----+
- -t ed25519: 최신 공개키 알고리즘
- -C "...": 계정 식별용 주석
- -f ...: 저장 위치 지정
- Enter passphrase는 빈칸 엔터로 하면 비밀번호 없이 사용 가능. (보안 목적상 설정해도 좋음)
- ~/.ssh/id_ed25519_todomate ← 비공개 키
- ~/.ssh/id_ed25519_todomate.pub ← 공개 키
공개키 복사 및 Github 붙여넣기
% cat ~/.ssh/id_ed25519_{SSH Key명}.pub
ssh-ed25519 ~~~~~ # 복사
- Github - Settings - SSH and GPG keys - New SSH Key - Key 붙여넣기 - Add SSH Key
~/.ssh/config 수정 (push 작업 시 자동 반영)
% vi ~/.ssh/config
Host github-alias # 약칭, 디텍토리별 반영되게끔 구성
HostName github.com # 고정, 그대로 입력
User git # 고정, 그대로 입력
IdentityFile ~/.ssh/id_ed25519_{SSH Key} # 생성해두었던 비밀키 경로
작업 디렉토리(레포지토리)에 SSH 반영
% cd {작업 디렉토리}
% git remote set-url origin git@{github-alias}:{Organation}/{Repository.git}
- github-alias 부분에 ~/.ssh/config 내 Host가 동작하여 레포지토리별 계정 SSH가 반영될 수 있음
728x90
반응형
'Develop' 카테고리의 다른 글
[Python] 텔레그램 채널 알림 시스템(봇) 만들기 (with BotFather) (0) | 2025.06.17 |
---|---|
[nodejs] CORS Preflight 완전 정복 - 브라우저가 먼저 “실례합니다!” (1) | 2025.06.04 |
[React] dyld: Library not loaded: /usr/local/homebrew/opt/icu4c/lib/libicui18n.74.dylib (0) | 2024.12.10 |
[Python] except 상세 logging 방법 (1) | 2024.11.27 |
[Python] SyntaxError: f-string: unmatched '[' 원인 및 해결 방법 (0) | 2024.11.26 |
[Docker] docker-compose 실행 및 중지, 테스트 방법 (0) | 2024.11.25 |
[Python] extend()로 List 자료형에 List 요소 추가하기 (2) | 2024.11.18 |
[Python] BeautifulSoup select() CSS 선택자 사용법 (4) | 2024.11.17 |