본문 바로가기

Git

Git push 인증 에러 해결 방법

새로운 branch 생성하고 작업내역 commit 이후 명령어로 git push origin 브랜치명 입력했더니, 갑자기 Username과 Password를 입력하라고 나온다. 제대로 입력했더니 다음과 같은 오류가 발생했다. 

 

터미널 오류 내역

git push origin feature/1-interface
Username for 'https://github.com': 사용자명
Password for 'https://사용자명@github.com': 패스워드 입력
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/사용자명/레파지토리명/'

 

원인

터미널에 상세하게 오류가 나왔다. 2021년 8월 13일 패스워드 인증 지원방식이 없어졌다. 저 URL에서 확인해보라고 나왔고 내 깃허브 레파지토리는 인증 실패했다고 나온다. 

 

해결 방법

구글링 해보니 Github에서 인증 token을 따로 생성 후 접근해야 해결할 수 있다.

1. Github > Settings > 좌측 메뉴 중 하단 Developer settings > Personal access tockens > Tockens(classic)

2. Generate new token(classic) 버튼 > 패스워드 입력 > 토큰명(note), 유효기간(expiration), Select scopes(repo 체크) > Generate token 버튼 클릭 후 토큰 생성 -> **토큰 값 복붙 후 따로 저장해두기

3. Mac기준, keychain 키체인 접근 설정에서 github.com 기존 키체인 삭제

4. 터미널 열기 > username 및 email 등록

git config --global user.name "username"
git config --global user.email "email@email.com"

5. 다시 오류 화면에서 git push 진행 후 username 입력 > password는 token 토큰 값 입력

 

출처

https://dev.classmethod.jp/articles/resolving-github-token-authentication-errors/