ls ~/.ssh/
查看是否存在***.pub
類文件
若是存在將其內容複製到git添加git
ssh-keygen -t rsa -C 「your_email@example.com」
提示保存路徑Enter file in which to save the key :
回車便可,
接着會讓你輸密碼,能夠不用輸密碼,直接回車。dom
The key's randomart image is: +---[RSA 3072]----+ | .++=*+| | o=.+| | ..= + | | + . o.= | | . So o ....| | o.=o . .o.| | o + = ++o o| | = Bo=.oo| | o.o.+. E| +----[SHA256]-----+
看到這個你的key
算是生成了
接下來在你的git帳戶裏面添加SSH Keys便可。
若是你在clone
或者pull
時出現permission denied或者仍是讓你輸密碼時,能夠嘗試下面的方法解決:ssh
先確認ssh-agent
處於啓用狀態:code
eval 「$(ssh-agent -s)」
輸出相似於:it
Agent pid 32070
而後將SSH key
添加到ssh-agent
:io
ssh-add ~/.ssh/id_rsa
若是你在建立key時輸了密碼,會提示email
Enter passphrase for /home/xxx/.ssh/id_rsa:
輸入密碼,而後回車便可,再去git
操做。file