local에서 작업 후 서버에서 github를 통해 다운로드를 받으려고 했더니 문제가 발생했다. SSH 관련한 인증 문제다.
SSH(Secure Shell): 원격 호스트에 접속하기 위해 사용되는 보안 프로토콜.
SSH 프로토콜을 사용하여 원격 서버와 서비스에 연결하고 인증할 수 있다. SSH키가 있다면 username과 personal access token 없이도 GitHub에 연결할 수 있다. 커밋할 때도 마찬가지.
SSH 키를 생성해 GitHub와 내가 키를 나눠가지면 이 키를 가지고 안전한 통신을 할 수 있다. 이전 포스트 - 암호화 글 참고
다음 단계로!
$ ssh-keygen -t ed25519 -C "your_email@example.com"
or
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-keygen 옵션들
-b: 생성할 키의 비트수 지정. 최소 768, default 2048.
-C: 주석 입력 가능, 서버에 따라 특별한 용도로 사용됨.
-t: 암호화 방식 지정
-f: 저장할 파일명이나 경로 지정 가능
> Enter a file in which to save the key (/c/Users/YOU/.ssh/id_ALGORITHM):[Press enter]
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
RSA를 이용해 키 생성을 완료할 경우 id_rsa와 id_rsa.pub 두 개의 파일이 만들어진다.
id_rsa.pub는 공개키로 github에 등록해야한다.
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_ed25519
or
$ ssh-add ~/.ssh/id_rsa
$ clip < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard
$ ssh -T git@github.com
> The authenticity of host 'github.com (IP ADDRESS)' can't be established.
> RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
> Are you sure you want to continue connecting (yes/no)? yes
> Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
$ git clone git@github.com:(계정명)/(repo명).git
문제 해결!!