본문 바로가기
Programming/Git

[Git] git push error - 토큰 인증 (Please use a personal access token instead)

by guru_k 2021. 11. 25.
728x90
반응형

git repository 를 생성하고 local 에서 reomte 로 push를 하려고 할때 아래와 같이 authentication 에러가 발생할 때가 있다.

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/kgmhk/test.git/'

이는 기존에 git 에서 사용되던 ID / PWD 방식의 인증을 금지하고 ID / Personal Access Token 방식의 인증을 요구하고 있기 때문이다.

그래서 새로운 저장소에 push 하는 경우 기존처럼 ID / PWD 입력만으로 인증이 되지 않는다.

그럼 해당 에러를 해결하기 위해 토큰을 이용한 인증 로그인 방법을 알아보자.

1. github 로그인

https://github.com/ 에 접속하여 로그인을 진행 한다.

2. Development Settings 접근

우상단 Profile -> Settings -> Development Settings 로 이동

 

3. 토큰 생성

왼쪽 메뉴에서 Personal access tokens 클릭 후 Generate new token 클릭

 

토큰 용도와 권한 Scopes 를 지정하고 토큰 생성을 클릭한다.

현재는 repo 에 권한 요청을 위해 사용할 예정 이므로 Repo에 체크 후 생성하자

 

이후 토큰이 발급된다. 해당 토큰은 발급 이후 다시 조회가 안되므로 추후 사용을 위해 저장을 해놓자.

 

4. 토큰을 사용하여 git push

이후 발급된 토큰을 사용하여 git push 하여 remote 환경에 커밋을 해보자.

git push 시 요청되는 PWD 항목에 토큰을 사용하면 된다.

$ git push --set-upstream origin main
Username for 'https://github.com': test@gmail.com
Password for 'https://test@gmail.com@github.com': <발급된 토큰 입력>
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 424 bytes | 424.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/kgmhk/test.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
728x90
반응형

댓글