본문 바로가기

열정가득한 개발자의 이야기/개발자의 일지

unable to access 'https://github.com/.git/': The requested URL returned error: 403 해결

 

git에서 한 번씩 403 에러가 뜨는데 거의 remote를 잘 못 설정해 줘서 remote 확인하고 set-url로 다시 지정해 주면 

얼추 다 해결은 됐었습니다.

근데 이번엔 안되더라구요..허허 

 

거의 2시간 해맸네요

일단 제가 시도했던 방법을 정리했습니다.

 

1. username확인 -> 잘되어있었음

제 컴퓨터이기도 하지만 사적인 컴퓨터가 아닌 회사꺼라서 혹시나 이름이 잘못 설정되어있을까 봐 git config에서 확인해 봤습니다.

명령어 : git config --global user.name

-> 너무 잘 되어있어서^^ 허허.. 차라리 여기가 문제였으면 얼마나 좋아..

 

2. remote문제 있은가 하고 remote 갈아엎기

명령어 : git remote remove 'branch이름' -> git remote add origin https://github.com/유저이름/레포이름. git

잘 됐으면 git remote -v로 잘 들어갔는지 확인해 주세요

근데 전 잘 들어갔음에도 불구하고  push 했더니 또 

fatal: unable to access ~ The requested URL returned error: 403 문제가 뜨더라고요,..

이때부터 눈 뒤집혔습니다. 네가 되나 내가 되나 해보자로 구글링 죽였습니다.

 

3. set-url의 다른 방식

어느 곳에서는 아래와 같이 ssh를 사용해서 하라고 하더라고요? 처음 보는 방법이라서 바로 도전했습니다. 

명령어 : git remote set-url origin ssh://git@github.com/유저이름/레포이름. git

이거 한 다음 push 해줬는데 오류 내용이 바뀌었어요

The authenticity of host 'github.com (~)' can't be established.
~~ key fingerprint is SHA~~~

This key is not known by any other names.
Please type 'yes', 'no' or the fingerprint: yes -> yes로 진행
Warning: Permanently added 'github.com' (~) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

오호라.. 변화가 보여서 그 변화에 따라 해결책을 찾았습니다. 

 

ssh key 생성

명령어 : ssh-keygen -t rsa -C github메일 주소

그러면 아래와 같은 내용이 나옵니다. 

 

Generating public/private rsa key pair.
Enter file in which to save the key (C:~): 
Enter passphrase (empty for no passphrase): 
Your identification has been saved in C:~.
Your public key has been saved in C:~.
The key fingerprint is:
The key's randomart image is:
+---[]----+
|          |
|          |
|           |
|..        |
|.        |
|             |
|              |
|           |
|              |
+----[]-----+

 

명령어 :  cat ~/. ssh/id_rsa.pub로 잘 생성되었는지 확인해 주시면 ssh 암호가 나와요

그거 복사하셔서  Settings -> SSH and GPC Keys -> New SSH key -> Key 부분에 위에서  ssh키 넣어주시면 됩니다. 

 

 

 

참고 : 

https://haejun0317.tistory.com/271

https://ssscool.tistory.com/637#google_vignette

https://engineeringcode.tistory.com/326

https://docs.github.com/ko/get-started/getting-started-with-git/setting-your-username-in-git

https://soda-dev.tistory.com/72

https://ssscool.tistory.com/637#google_vignette