Git SSH Key 生成

前端开发项目实战视频百度云
web前端开发视频讲解
小程序前端开发视频

git clone命令从github上同步github上的代码库时,如果使用SSH链接,而你的SSH key没有添加到github帐号设置中,系统会报下面的错误:
fatal: Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.
原因是Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置。

github的SSH配置如下:

一 、
设置Git的user name和email:
$ git config –global user.name “用户名”
$ git config –global user.email “邮箱地址”

二、生成SSH密钥过程:

1.查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
2.生存密钥:
$ ssh-keygen -t rsa -C “邮箱地址”
按3个回车,密码为空。

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)?

三、打开github帐号管理中的添加SSH key界面的步骤如下:

  1. 登录github
  2. 点击头像下拉菜单的settings图标

3.选择SSH AND GPG keys

 4. 点击 Add SSH key
    在出现的界面中填写SSH key的名称,填一个你自己喜欢的名称即可,然后将上面拷贝的~/.ssh/id_rsa.pub文件内容粘帖到key一栏,在点击“add key”按钮就可以了。

四、把某个库拷贝到你的硬盘
$ git clone SHH链接;
例如:$ git clone git@github.com:ruanyf/react-demos.git

前端开发0基础视频 知乎
前端开发视频网
网易云前端开发视频
赞(0)
前端开发者 » Git SSH Key 生成
64K

评论 抢沙发

评论前必须登录!