git/github 生成密钥

一 .  github上创建立一个项目

  用户登录后系统,在github首页,点击页面右下角“New Repository”

  填写项目信息:

  project name: hibernate-demo  

  description : my first project

  点击“Create Repository” ; 现在完成了一个项目在github上的创建。

二  .  创建密钥

  (1).配置用户名和邮箱(如果已经配置,就跳过)

    git config –global user.name ‘xxxxx’ 
    git config –global user.email ‘xxx@xx.xxx’

   (2).检查下自己之前有没有已经生成shh

        cd ~/.ssh

      如果能进入到.ssh文件目录下 ,则证明,之前生成过.ssh秘钥,可以直接使用里面的秘钥。 

  (3).生成秘钥 

      ssh-keygen -t rsa -C ‘xxx@xx.xxx’ //配置的邮箱

      接着按3个回车 :      

 1 Generating public/private rsa key pair.
 2 Enter file in which to save the key (/c/Users/Mr.Yang/.ssh/id_rsa):
 3 Enter passphrase (empty for no passphrase):
 4 Enter same passphrase again:
 5 Your identification has been saved in /c/Users/Mr.Yang/.ssh/id_rsa.
 6 Your public key has been saved in /c/Users/Mr.Yang/.ssh/id_rsa.pub.
 7 The key fingerprint is:
 8 SHA256:zA6wNJrFB6NcqS6eBog/AHlzQuvFjYpG759Yhh1lWGI xxxxxx@xxxxx.xxx(上面自己的邮箱)
 9 The key's randomart image is:
10 +---[RSA 2048]----+
11 |    +E .         |
12 | ..+oo+          |
13 | oo+*+.o         |
14 |o.*===+o         |
15 |==+*... S        |
16 |B.+.o .o         |
17 |++o. +  .        |
18 | +o.+ .          |
19 |.  o.o           |
20 +----[SHA256]-----+

 

  最后在.ssh目录下得到了两个文件:id_rsa(私有密钥)和id_rsa.pub(公有密钥)

   .  将公有密钥添加到github SSH keys

    使用记事本等软件打开id_rsa.pub文件,将里面的内容复制,粘贴到github的New SSH key

四 .验证是否连接成功

  $ ssh git@github.com

posted @ 2017-10-19 10:31  hooyun  阅读(4428)  评论(0编辑  收藏  举报