前置#
確保終端機可以正常使用 git 和 ssh-keygen 命令
檢查系統內是否已經有 ssh 金鑰#
在 Linux、MacOS 終端機執行:
ls ~/.ssh
git 全局配置#
git config --global user.name 你的使用者名稱
例如:git config --global user.name zhiao
git config --global user.email 你的電子郵件
例如:git config --global user.email [email protected]
生成金鑰#
ssh-keygen -t rsa -C '你上面git配置的電子郵件'
例如:ssh-keygen -t rsa -C '[email protected]'
將公鑰貼到 Github#
進入 github-> 右上角頭像 ->setting->SSH and GPG keys->New SSH key
- 輸入標題
- 在終端機進入~/.ssh 目錄,將以.pub 結尾的文件內容貼到 Key 中
- 點選 Add SSH key