发布于 

linux下通过git连接github

Ubuntu下搬砖

安装git

Sudo apt-get install git

配置环境

Git config --global user.name "github的用户名"
Git config --global user.email "github的邮箱"

配置本地ssh密匙

ssh-keygen -t rsa -C "github的邮箱"

从配置完本地ssh密匙之后可一直点击enter按键,直到出现

   The key's randomart image is:××××××××××   
  • 注意:在这句代码之前的Generating public/private rsa key pair.
    Enter file in which to save the key ((这个目录是随机的如果提前就在root权限下配置的便为固定目录)root/.ssh/id_rsa)
  • 便切换到那个目录/.ssh下:Cd /root/.ssh/

获取密匙并存入

通过Git bash输入:
 cat id_rsa.pub 

获取的字符一个不少的复制到github已登录状态下的设置里的ssh和gpg的密匙
在ssh keys新创建一个文件 标题测试随意填(这个不影响连接使用) 其下密匙直接将刚刚复制下来的获取源一个不漏的粘贴 保持就好了

继续输入:
ssh -T git@github.com

回车即可 若在日志看到

You’ve successfully authenticated, but GitHub does not provide shell access.
则表明连接成功.