본문 바로가기

ETC

Github SSH 등록 및 설정 / authentication 방법 변경

 

서버와 로컬을 git에 연결해서 작업중인데

서버에서 git 아이디, 비밀번호를 치니까 갑자기 나온 에러

 

 

 

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: unable to access 'https://github.com/1234567890.git/': The requested URL returned error: 403

 

 

 

 

일단, 명시해준 사이트에 들어가 보았다.

Token authentication requirements for Git operations

https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

 

Token authentication requirements for Git operations | The GitHub Blog

Beginning August 13th, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

github.blog

핵심

2021년 8월 13일부터 Git 작업을 인증할 때 더 이상 계정 비밀번호를 허용하지 않으며 개인 액세스 토큰(개발자용) 또는 OAuth 또는 GitHub 앱 설치 토큰(통합업체용)과 같은 토큰 기반 인증을 사용해야 합니다. GitHub.com에서 인증된 모든 Git 작업에 대해 원하는 곳에서 SSH 키를 계속 사용할 수도 있습니다. (해당 사이트 번역)

 

그래서 현재 서버에서 비밀번호로 git push, pull 하던 방식을 SSH 나 토큰인증으로 변경해야했다.

나는 서버는 SSH 키로 변경하기로 함 

 

일단, 서버에 있는 SSH 키 먼저 확인 (이미 생성해 둔 상태였다.) 

생성방법이 궁금하다면, 참조사이트  https://jootc.com/p/201905122827

 

 

 

 

1. 생성된 SSH를 복사해서 github에 저장하기 위해 해당 폴더로 이동

cd ~
cd .ssh
ll

id_rsa : 개인키 / id_rsa.pub : 공개키

 

 

 

 

 

2. 공개키 복사

cat id_rsa.pub

해당 명령어 입력하면 공개키가 복사된다. 

 

 

(ssh-rsa AAAAB3........................................)

 

 

 

 

 

3. 해당 공개키 복사 후 github 이동. profile > Settings

 

 

 

 

 

 

 

4. SSH and GPG keys 클릭 > New SSH key 클릭

 

 

 

 

 

 

5. SSH 키 저장

Title은 그냥 SSH키 이름 작성 (아무거나 상관없음) Key 부분에 복사한 키 넣고 Add SSH key 클릭

 

 

 

 

 

6.  Github SSH 주소 복사 후 서버에 remote 연결

해당 주소 복사 후, 

서버에서 git remote add [remote명] [SSH복사주소] 입력 후 사용

 

 

이후 push, pull 시 remote명 주소 이용해서 사용하면 된다.

비밀번호 치지 않아도 되서 훨씬 편하고 간편했다.

 

 

 

 

 

20210923 추가 

 

/ 이후 서버변경 작업을 하면서 ssh에 자꾸 에러가 나기 시작했다. 

(아무래도 SSH 적용하면서 이전꺼랑 꼬인듯 하다)

Enter passphrase for key '/root/.ssh/id_rsa': 
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

이때 rm ~/.ssh/id* 명령어를 통해 SSH를 지우고, 다시 만들어 위에 방법으로 재적용 후 사용했다.

 

참고사이트 

https://hellowwworld.tistory.com/4

반응형