美文网首页
GitHub_clone with ssh下载代码

GitHub_clone with ssh下载代码

作者: 小盼盼_1 | 来源:发表于2020-05-04 16:28 被阅读0次

Github上下载代码有两种方式,一种是download zip,一种是clone with ssh。本文重点说明下clone with ssh的一些操作步骤。

centos服务器上增加ssh key

1.打开服务器,输入命令ls ~/.ssh,查看返回结果

a.结果包含Is a directory或者No such file or directory,说明当前服务器未包含ssh key,此时需要新建一个ssh key。

b.结果如下图所示的话,则可以直接看操作步骤4即可。

GitHub_clone with ssh下载代码

2.输入命令ssh-keygen -t rsa -C “自己的邮箱”[创建SSH Key],会出现下面两行命令

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

此处是想输入一个文件名,保存刚生成的SSH Key,可以填写,也可忽略,此处我选择了忽略,直接点击enter进入下一步[默认会生成id_rsa和id_rsa.pub两个密钥文件]

3.Enter passphrase (empty for no passphrase)&Enter same passphrase again,设置及再次确认密码[使用ssh传输文件的时候需要使用],此处设置与Github账号一样的密码,方便好记。此时ssh key已经设置完成。

4.拷贝/root/.ssh/id_rsa.pub的内容,执行命令cat /root/.ssh/id_rsa.pub,将输出结果复制下来。

GitHub_clone with ssh下载代码

添加SSH Key至Github

GitHub_clone with ssh下载代码

将前面复制下的内容贴到GitHub的ssh keys处,贴完之后,查看下载代码处就可以clone with ssh了。

GitHub_clone with ssh下载代码

服务器上clone代码

1.服务器上输入ssh -vT git@github.com,出现如下提示语,说明已经设置成功

Hi xiaopan868! You've successfully authenticated, but GitHub does not provide shell access.

2.输入自己想clone的代码分支:git clone git@github.com:crisschan/Battle.git,相应的代码即可clown下来

相关文章

网友评论

      本文标题:GitHub_clone with ssh下载代码

      本文链接:https://www.haomeiwen.com/subject/nqhyghtx.html