Mac系统下查看和生成SSH Key

1、打开vim(terminal.app)查看本地是否存在SSH-Key

 

  # ls -al ~/.sshvim

 

>> 若是vim输出的是以下内容:证实本地没有生成的SSH Key,请执行第二步。app

 

  # No such file or directoryssh

 

>> 若是vim输出的是以下内容: 证实本地已经存在SSH Key 文件,请执行第四步。terminal

 

  # id_rsa        id_rsa.pubit

 

2、若是没有,生成新的SSH Key

 

  #ssh-keygen -t rsa -C"you_email"email

 

your_email:这里填写你在GitLab或者GitHub注册时的邮箱。file

 

后面的提示直接敲回车,一路完成。rsa

 

3、生成并添加SSH Key

 

  # ssh-add ~/.ssh/id_rsaim

 

4、查看SSH Key

 

  # cat /Users/xxx/.ssh/id_rsa.pubssh-key

 

xxx是你的电脑用户名,例如:howieMacBook-Pro:~ howie$中的howie关键字。

 

复制生成好的SSH Key 添加到 GitLab 或者GitHub中的SSH Key中便可。

相关文章
相关标签/搜索