Header Banner
Kakao Logo

TECH.KAKAO.GG

기술 자료/Git/Git SSH 인증 오류 해결 가이드

Git SSH 인증 오류 해결 가이드

Git약 1개월 전
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Git에서 SSH 프로토콜을 통해 GitHub 리포지토리에 접근하려 했으나, 인증에 실패하여 발생합니다. SSH 키 인증이 정상적으로 되어 있지 않거나, 리포지토리에 대한 권한 부족이 원인일 수 있습니다.

 

전제 조건 확인

1. SSH 연결 확인

ssh -T git@github.com

정상적인 응답

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.

2. 리모트 URL 확인

git remote -v

출력 예시

origin  git@github.com:Organization/server.git (fetch)
origin  git@github.com:Organization/server.git (push)

 

주요 원인 및 해결 방법

원인 1. SSH 키 등록 누락

  • ~/.ssh/id_ed25519.pub 또는 ~/.ssh/id_rsa.pub 등 공개 키가 GitHub에 등록되어 있지 않으면 인증 실패

  • 해결 방법:

    1. 키 생성: ssh-keygen -t ed25519 -C "your_email@example.com"

    2. SSH Agent 등록: ssh-add ~/.ssh/id_ed25519

    3. 공개 키 등록: GitHub > Profile > Settings > SSH and GPG keys > New SSH Key

 

원인 2. 잘못된 SSH 키 사용

  • 여러 SSH 키를 사용 중일 때, 예상과 다른 키가 선택되어 인증 실패

  • 해결 방법:
    ~/.ssh/config 파일에 명시적 지정 추가

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

 

원인 3. 리포지토리 푸시 권한 없음 (Organization에서 자주 발생)

  • git@github.com:Organization/server.git는 조직 리포지토리로, test 계정이 write 권한이 없을 수 있음

  • 해결 방법:

    • 조직 관리자에게 권한 요청

    • 또는 본인 계정으로 Fork 후 Push

키워드

SSH 키 인증 실패GitHub 리포지토리 접근 권한SSH 구성 및 문제 해결Git SSH 인증 오류 해결