will come true

[Git] SourceTree에서 원격저장소에 Push할 때 Repository 접근 인증 에러 해결 본문

Etc.

[Git] SourceTree에서 원격저장소에 Push할 때 Repository 접근 인증 에러 해결

haehyun 2021. 8. 22. 23:16

문제상황

자신의 Github Repository를 원격저장소로 추가한 뒤, 로컬에서 변경된 사항을 원격저장소로 Push하는 과정에서 Github username, password를 제대로 입력했음에도 에러가 발생하며 Push가 이뤄지지 않음. 참고로 cmd 창에서 커맨드로 push명령을 하면 잘만 수행됨.

 

원인

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --tags --set-upstream origin main:main remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. fatal: Authentication failed for 'https://github.com/{user_name}/{repository_name}/'

 

= 요약 : 비밀번호 인증 지원이 2021년 8월 13일에 끝났으니, 앞으로는 개인 액세스 토큰을 사용해서 인증받으라는 뜻.
(상세 내용: https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/)

 

해결법

에러 메시지에서 설명한 대로 2021년 8월 13일 이후로는 Github에 접근하는 서비스 앱은 "Personal Access Token"을 이용해서 Github Repository에 접근할 수 있다. 

 

1. 우선 Personal Access Token을 발급 받으러 GitHub로 돌아간다. 프로필 클릭 > [Settings] > [Developer Settings]

 

2. [Personal access tokens] > [Generate new token]

 

3. 토큰 생성 목적, 만료기한, 토큰 접근 범위 등을 지정해준 뒤 [Generate token] 클릭

 

4. 토큰 생성이 완료되면, 화면에 표시된 토큰을 복사해서 따로 저장해둔다.

 

이제 해당 토큰을 SourceTree 인증에 사용할 차례이다.

그러나 SourceTree에서 아무리 Push를 눌러도 앞에서 입력한 패스워드로 인증이 시도되기 때문에 토큰으로 인증을 시도하기 위해서는 현재 패스워드 기록을 지워야 한다.

 

5. 파일탐색기에서 아래 경로로 접근한다.
> C:\Users\{사용자명}\AppData\Local\Atlassian\SourceTree

 

6. 위 경로에 "passwd"라는 파일이 존재할텐데, 이 파일을 삭제해준다.

 

7. 다시 SourceTree로 돌아가서 Push 과정을 수행하면 처음과 같이 로그인 인증창이 표시된다.

 

8. Password 입력 칸에 앞에서 생성한 토큰 값을 입력한 뒤 [Login]을 클릭한다.

 

9. 토큰 키를 제대로 입력했다면 별다른 이상없이 Push 과정이 수행된다.

 

Comments