프로그래밍/Git

Git Permission denied (publickey) 에러 해결

Beginner:) 2023. 2. 25.
320x100

The authenticity of host 'github.com (IP)' can't be established.
ECDSA key fingerprint is SHA256.
Warning: Permanently added 'github.com,IP' (ECDSA) to the list of known hosts.
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.

 


 

VSCode로 라즈베리 SSH 연결을 하여 개발을 하다 Git Push를 시도하는데 만난 에러

원인은 SSH 원격으로 수행하기 때문에 나타난다는데 ssh키를 등록해야한다고 한다.

id, pw로 접속했고 원격 컴퓨터에서 보내는건데 보안이 필요한가...? 음 

어쨋건 Git hub에 ssh 키를 등록해주자.

 

1. ssh key 생성

key는 원격 환경에서 생성해야한다.

나의 경우 Windows 에서 Linux로 ssh 접속하여 Linux에서 push를 하는 경우이니 Linux에서 key를 생성한다.

 

아래의 명령어를 입력하고 file path와 비밀번호는 default로 그냥 넘긴다.

ssh-keygen -t rsa -C "깃 이메일 형식 계정"

 

그러면 해당 경로에 파일이 생긴다.

 

그 중 id_rsa.pub 파일내용을 복사한다.

메모장, cat 명령어 등을 사용한다.

 

2. Git hub 등록

Git hub에 로그인하여 본인 계정의 Settings로 접속한다.

 

좌측 메뉴에서 "SSH and GPG keys"를 클릭한다.

 

New SSH key 클릭

 

Key 값을 입력한 뒤 Add SSH key

 

 

3. 다시 git을 사용한다.

push 작업이 이루어지는 것을 볼 수 있다.

반응형

'프로그래밍 > Git' 카테고리의 다른 글

[Git] 4. branch(2)  (0) 2023.06.05
[Git] 3. branch(1)  (0) 2023.05.31
[Git] 계정 자동 로그인(feat. VSCode)  (0) 2023.05.29
[Git] 2. Commit (feat. log, diff)  (0) 2023.05.27
[Git] 1. Git stage (feat. tracked 상태란)  (0) 2023.05.24

댓글