git@github.com: Permission denied (publickey)

MURRAIYA·2024년 2월 28일

깃허브 설명을 착실하게 따라가다가

git clone git@github.com:uzh-rpg/rpg_svo_pro_open.git

github 주소를 복사해다 넣는 git clone과 달리 생소한 명령어를 만났다.

Cloning into 'rpg_svo_pro_open'...
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 clone 에는 두 가지 방법이 있다.

HTTP연결로 git clone

흔히 쓰는 방법으로 github에서 링크를 복사한 뒤 붙여넣는 방식

git clone https://-- 

SSH 연결로 git clone

  1. 컴퓨터에서 SSH Key 생성 후 github에 등록
  2. ssh연결로 clone
git clone git@github.com:{USR_ID}/{repo_name}.git #이 페이지의 맨 위 커맨드 참고

SSH key 등록

따라서 원인은 내 github.com에 ssh key가 설정되지 않아서이고

이제 ssh key를 만들어 나의 github 계정에 등록하면 된다.

//rsa(공개키 알고리즘 방식)으로 ssh-key를 만들어라
ssh-keygen -t rsa -C "[github email]"

명령어를 치고 나면 어디에 키를 생성할지 지정하라고 나오는데 Enter를 치면 기본위치에 저장된다. passphrase(비밀번호)를 지정하는 것도 패스.

identification, public key, key fingerprint가 생성되었다고 나온다.

여기서 아까 필요했던 키는 ~/.ssh/id_rsa.pub 에 저장된 public key이다.

 cat ~/.ssh/id_rsa.pub

복사한 후 깃허브 계정의 settings에 가서 new ssh key를 등록해준다. title은 상관 없음.

이 키를 공개하면 나의 깃허브가 만인의 것이 되는 것이니 잘 지키면 된다.

ssh 키가 terminal을 연 컴퓨터에 저장되어 있는 것이기 때문에 다른 컴퓨터를 쓰게 된다면 ssh key 설정을 다시 해야 할 것으로 보인다.

이후 이어서 원하는 명령어를 칠 때 처음에 신뢰할지 묻는 내용이 나온다.

The authenticity of host 'github.com (52.78.231.108)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no)?

이렇게 나오면 습관적으로 Enter 치지 말고 yes라고 예쁘게 써줘야 된다.

profile
🙃SUJI KIM🙃 🚩 Inha University Undergraduate 🚗 Autonomous Driving Robots 📷 Computer Vision 💫 SLAM

0개의 댓글