데브옵스/CI,CD

[GitHub] private 레퍼지토리 clone 하기

SparkIT 2024. 12. 31. 01:32
ubuntu@ip-xxx-xx-xx-xx:~$ git clone https://github.com/SHINDongHyeo/app.git
Cloning into 'app'...
Username for 'https://github.com': 내 깃허브 유저이름 입력
Password for 'https://SHINDongHyeo@github.com': 내 깃허브 비밀번호 입력
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/SHINDongHyeo/app.git/'

저는 그동안 개인적으로 개발했던 코드를 배포하기 위해 AWS EC2 인스턴스에 SSH 접속 후 git clone 명령어를 사용했습니다. 하지만 위와 같이 에러가 발생했습니다. 그 이유는 해당 레포지토리가 private 레포지토리였기 때문입니다. 에러 문구를 확인하면 알 수 있듯이 private repository를 클론하기 위해서 아이디, 패스워드를 입력하는 방식이 더 이상 허용되지 않습니다. 그럼 어떻게 private repository를 clone할 수 있을까요?

 

Personal Access Token 발급받기

github에서 private repository를 clone 하기 위한 토큰을 발급받아야 합니다. github에서 'Settings > Developer settings > Personal access tokens'으로 이동합니다. 저는 Tokens(classic)을 선택했습니다.

 

그리고 저는 간단하게 레포지토리를 clone만 하는 용도로 사용할 것이기에 repo만 체크해주었습니다. 그리고 Generate token 버튼을 눌러 해당 토큰을 발행했습니다.

 

git clone 하기

github 유저명과 액세스 토큰을 git clone 명령어에 포함시킵니다.

git clone https://깃허브유저명:깃허브퍼스널액세스토큰@깃허브레포지토리URL

 

해당 명령어를 통해 private repository를 성공적으로 clone할 수 있었습니다.