2023. 11. 2. 13:53ㆍToday I Learned (TIL)
원래는 git 계정을 한개만 연결해서 사용하다가, 개발자 계정으로 새로 계정을 만들어 vscode를 사용하려고 한다. 그런데 vscode 상에서 이미 연결된 계정이 있어서 로그인을 하면 이전 이메일 계정으로 자동으로 연결되곤 해서 굉장히 불편했다. vscode를 틀면 git에 연결하겠냐고 보통 알림이 오는데 그때 자동으로 연결되는 url을 연결하고 싶은 이메일 계정으로 연결을 하니 vscode 상에서는 원하는 계정으로 로그인이 되었다. 다만... 이 계정으로 git push 를 하는데 아래와 같은 에러가 뜨면서 내 repository로의 연결이 잘 되지 않았다.


에러메시지:
>git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
https://stackoverflow.com/questions/7318918/fatal-does-not-appear-to-be-a-git-repository
fatal: does not appear to be a git repository
Why am I getting this error when my Git repository URL is correct? fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly ...
stackoverflow.com
위 사이트를 보면서 해결했는데, 하라고 하는 해결법은 다 해보다가 결국 ssh public key를 git에 연결해야 한다는 사실을 알게 되었다. ssh public key는 지난번에 vscode 상 계정 두개를 쉽게 연결하는 방법을 찾아보다가 만들어놓았었다. ssh public key가 없다면 생성해야 한다. 방법은... 추후에 포스팅하겠다.
Private key와 Public key가 있는데, private key는 업로드하면 안되고,
id_rsa.pub 파일 안에 있는 public 키를 복사해서, git 계정안에 SSH key에 붙여넣어 key새로 만들어 준다.

뻘짓하다가 조금 어이없게 public key 생성으로 vscode git 연결이 가능해진 이야기였슴다🐥
'Today I Learned (TIL)' 카테고리의 다른 글
| [TIL] Front-Back 연결 trouble shooting and solution - corsheaders, CORS_ALLOWED_ORIGINS (1) | 2023.11.09 |
|---|---|
| TIL. setting up PostgreSQL, collectstatic using GPT (0) | 2023.11.08 |
| Git 명령어, 단축키, 도구모음 (1) | 2023.11.01 |
| What is API (Application programming interface)? (0) | 2023.10.22 |
| [TIL] vscode, python, django 유용한 명령어 모음 (0) | 2023.09.04 |