본문 바로가기

일::개발

MacOS Visual Studio Code에서 github push : Permission denied (publickey)

github에 push 할 때 터미널에서는 잘 되는데, Visual Studio Code에서 push 하면 Permission denied(publickey) 에러 뜨면서 실패하는 경우가 있다.

 

작업은 Visual Studio Code에서 하고 push만 터미널에서 하다가 좀 찾아보니,

Yosemite 이후부터 MacOS의 키 체인에 SSH passphrase 를 저장해도 reboot하면 날아가게 변경되었다고 한다.

 

해결책이라고 하는 게 몇 가지 있는데,

 

1. ~/.ssh/config 에 다음의 내용을 넣어준다.

Host * (asterisk for all hosts or add specific host)
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key> (e.g. ~/.ssh/userKey)

나의 경우(Big Sur, passphrase 설정)에는 동작하지 않음

 

2. ssh-add -K <key> 로 키체인에 추가한 이후에 reboot할 때마다 ssh-add -A 실행. LaunchAgent 에 .plist 파일 만들어서 추가하는 방식으로 처리.

 

시작 프로그램에 뭔가 넣는게 싫어서 패스

 

결국 ssh private key에서 passsphrase를 제거하는 것으로 타협 ㅠㅠ

 

> ssh-keygen -p

 

github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain