Git: Mac系统生成ssh key

233 阅读1分钟

查看之前有无生成过ssh key

$ cd ~/.ssh

if: cd: no such file or directory: /.ssh

$ ssh-keygen -t rsa -C"yourmail@qq.com"
一直回车即可

then:

$ cd ~/.ssh
$ ls
id_rsa id_rsa.pub

复制公钥,并粘贴到gitlab中

$ cat id_rsa.pub

image.png

设置git邮箱和用户名

$ git config --global user.name "your name"
$ git config --global user.email "your_email@youremail.com"

验证

$ ssh git@gitlab.com