首先生成密钥
#生成密钥命令
ssh-keygen -t rsa -C "your_email@youremail.com"
生成之后一个id_rsa 和一个 id_rsa.pub 。
pub后缀是公钥,加到github,个人设置里添加 ssh key。
私钥使用本地git添加
在命令行调用
# 添加私钥
ssh-add id_rsa
如果报错
could not open a connection to your authentication
可以调用
ssh-agent bash
之后可以正常添加私钥
使用下面命令可以列出已添加私钥
ssh-add -l
最后使用
$ ssh -T [your git repository]
Welcome to GitLab, @jixinqiang!
就可以无需代码pull、push、fetch了