環境
macOS
實作
-
生成 SSH Key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -
取得生成的公鑰
cat /Users/你的使用者名稱/.ssh/id_rsa.pub 例如:cat /Users/kunjili/.ssh/id_rsa.pub會輸出類似以下的內容,稍後設置會用到
ssh-rsa AAAAB3Nza(中間略)b9gOxL0tSVMBQ== kunji.li@outlook.com -
將公鑰設置到 Github
到 Github 頁面找到你的頭像
Settings

SSH and GPG keys

在 SSH keys 的地方選擇 New SSH keys

然後標題可以隨便取
內容輸入剛剛資料夾內的 id_rsa.pub 檔案全部內容
-
測試
新增成功後測試看看
ssh -T git@github.com成功的話會看到類似以下訊息
Hi occultationtw! You've successfully authenticated, but GitHub does not provide shell access.