ssh-keygen -t id_ed25519 -C "your_email@example.com"
如果不命名,默認名是 id_ed25519,一路回車。
如果你用的是舊系統,可以使用
rsa替代ed25519。
這時候會自動創建 .ssh 文件夾。
cd ~/.ssh
ssh-add ~/.ssh/id_ed25519
pbcopy < ~/.ssh/id_ed25519.pub
粘貼到 Github 的這個位置:
頭像 -> Settings -> SSH and GPG keys -> New SSH key
vi config
點擊鍵盤 i 鍵入以下資料
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519
# bitbucket
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/bitbucket_ id_ed25519
按 esc 編輯模式,鍵入 :wq 保存。
ssh -T git@github.com
如果顯示下面的提示就是成功了,如果沒有可能就要看一下上面的步驟有沒有出錯
Hi <user_name>! You've successfully authenticated, but GitHub does not provide shell access.
祝編程愉悅!
