本節內容:
- 錯誤原因
- 解決方案
一.錯誤原因
安裝完git,想要通過ssh的方式下載,需要本機生成公鑰與github上的賬號進行驗證,綁定,才能從github上通過ssh下載項目
二.解決方案
進入https://github.com/settings/profile查看自己的賬號和郵箱,記下來,下面會用到。
打開Git輸入命令git config –global user.name “yourname”回車
git config –global user.email“your@email.com”回車
ssh-keygen -t rsa -C “your@email.com”(填寫自己的郵箱地址)回車
接下來會出現:(一路回車就可以)
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
直到出現:
之后打開提示的目錄下記事本打開id_rsa.pub,復制里面內容。
進入自己的賬號https://github.com/settings/keys 點擊 New sshKey
復制的內容粘貼到Key里,Title可以不寫,親測
驗證:$ ssh -T git@github.com回車
Hi XXXXX! You’ve successfully authenticated, but GitHub does not provide shell access.
成功,接下來就可以從github上clone下來項目了。