본문 바로가기
학습 아카이브

[git/문제해결] fatal: Authentication failed for ~

by 125ryun 2025. 1. 18.
💻 개발 환경
- OS: macOS Monterey 12.7.6
- IDE: IntelliJ IDEA 2024.3.1.1 (Ultimate Edition)

 

🚨 문제 상황
github 원격 저장소에 push할 때 아이디와 비밀번호를 입력했는데 다음과 같은 에러 메시지와 함께 push되지 않음.
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/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/{username}/{repository}.git/'

 

🔍 원인
2021년 8월 13일부로 git 인증 방식이 아이디&비밀번호에서 토큰 인증 방식으로 변경됨. 

 

✨ 해결 방법
GitHub에서 토큰을 발급받아 인증 시에 사용한다.

 

1. GitHub 접속

🔗 https://github.com/
 

GitHub · Build and ship software on a single, collaborative platform

Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.

github.com

2. 설정에서 Developer settings로

설정 탭에 들어가서 쭉 내리면 맨 마지막에 나온다. 

3. Personal access tokens에서 토큰 발급

 

이때 토큰 만료 기한을 '없음', 즉 무기한으로 설정하면 편할 것 같지만 GitHub에서는 보안상의 이유로 추천하지 않는다는 경고 문구가 뜬다. 

실수로 토큰이 유출됐을 때 내가 알아차리지 못하면 영원히 누군가에게 이용당할 수 있으므로...

귀찮음과 보안성을 적절하게 잘 재고 따져서 만료 기한을 정하면 될 것 같다. 

토큰 발급이 완료되면 이렇게 토큰을 확인할 수 있으며 바로 클립보드에 복사할 수도 있다. 

이 토큰은 발급 직후에만 확인할 수 있고 이후에는 다시는!! 볼 수 없으므로 안전한 곳에 잘 메모해 두어야 한다. 

4. 터미널에서 사용자 관련 git 설정

터미널에서 아래 커맨드를 실행해 git 설정을 바꿔준다. 

username에는 GitHub username, password에는 아까 발급받은 토큰을 적으면 된다. 

git config --global user.name {username}
git config --global user.password {token}

5. git push :)

원격 저장소에 원활하게 push된다!