2월 20, 2022

ssh로 클론 받은 이후 origin push시 오류 발생

git push origin feature/yeongseo-initial-setting

깃헙 remote repo에서 ssh방식으로 clone을 받은 후, 해당 명령어로 origin에 push를 진행하려 했을 때 다음과 같은 오류를 마주했습니다.


no such identity: /home/park/.ssh/id_ed25519: No such file or directory 

[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.


.ssh/id_ed25519라는 파일 또는 디렉토리가 없다고 합니다

없으면 만들어주거나, 키를 가져오는 경로를 변경해야겠죠


경로 변경하는 법을 몰라서 만들어주기로 했습니다


https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys

깃허브의 설명에 따르면, GitHub을 위한 public keys의 filenmaes는 이 세개중 하나랍니다



저 같은 에러를 겪고 있는 사람들을 위한 설명도 밑에 있습니다. 새로운 SSH키를 만들라네요.


ssh-keygen -t -ed25519


이 명령어로 새로운 ed25519키를 만들어줍니다


~./ssh 안에 id_ed25519의 개인키와 pub키가 생성됐길래, 이제 될줄 알고 push를 다시 해줬습니다. 

그런데 이번엔 permission denied가 뜹니다.


만들기만 하고 키들을 등록해주는 것을 깜빡했습니다.


cat명령어를 통해 공개키를 확인하고, 깃허브에 이를 등록해줍니다.


ssh-add ~/.ssh/id_ed25519

위의 명령어로 개인키 또한 ssh-agent에 등록해줍니다. 


이제 push를 진행하니 문제없이 잘 됩니다.