1.判斷是否已經生成公鑰
cat ~/.ssh/id_rsa.pub
如果看到一長串以 ssh-rsa或 ssh-dsa開頭的字符串,則已經生成
2.生成ssh-key
ssh-keygen -t rsa -C "[email protected]"
這個指令會要求你提供一個位置和文件名去存放鍵值對和密碼,你可以點擊Enter鍵去使用默認值
3.獲取生成的公鑰
cat ~/.ssh/id_rsa.pub
備註:拷貝你的公鑰到你的粘貼板下
windows:
clip < ~/.ssh/id_rsa.pub
linux:
xclip -sel clip < ~/.ssh/id_rsa.pub
mac:
pbcopy < ~/.ssh/id_rsa.pub