【Git】為GitHub新增ssh配置
阿新 • • 發佈:2020-11-16
最近又是換電腦,又是換硬碟的,來來回回搞了好幾次,遂記錄一下,最簡單的流程。
1.為什麼要用ssh?
平時用的是https連結,所以push等操作都得輸入使用者名稱密碼,很煩,但是認證了ssh連結之後,就可以在此臺機器上隨意操作專案了。
2.本地部署ssh
Windows:
cd ~/.ssh #進入ssh資料夾 ssh-keygen -t rsa -C "[email protected]" #建立ssh key ... #回車使用預設檔名 Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter] #回車使用空密碼 Enter passphrase (emptyfor no passphrase): Enter same passphrase again: ... #出現如下表示建立成功 Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
#檢視公鑰
cat id_rsa.pub
#複製命令列顯示的公鑰
3.GitHub新增ssh
進入setting
4.測試ssh
ssh -T [email protected] ... Are you sure you want to continue connecting (yes/no)? #輸入yes回車 Enter passphrase forkey '/c/Users/Administrator/.ssh/id_rsa': #繼續回車 Hi username! You've successfully authenticated, but GitHub does not provide shell access.
大功告成~