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