解決 [email protected] permission denied (publickey) fatal: Could not read from remote repository.
輸入 git 指令時報錯:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
解決:
- 進入.ssh 資料夾
cd ~/.ssh - 產生鑰匙
ssh-keygen
輸入後會出現一些選項,基本上都 Enter 就可以了 - 複製.pub 內容
在.ssh 資料夾中,會出現兩個檔案,分別是公鑰和私鑰,.pub 是公鑰,我們要把內容放到 github 裡。
你可以用編輯器打開.pub 檔,或是用 cat 命令查看,然後將內容完整複製起來cat ~/.ssh/id_rsa.pub - 將密鑰貼至 github
Setting -> SSH and GPG keys
點擊 New SSH key
將剛剛複製的密鑰貼到 Key 中,送出
- 完成,現在再輸入 git 指令,就不會出現 Permission denied (publickey)報錯了
