gitHub添加公钥

gitHub添加公钥

  1. gitHub是通过SSH公钥连接到现有仓库的
  2. 设置SSH Key

    ssh-keygen -t rsa -C "your_email@example.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/mouMiFan/.ssh/id_rsa): //Enter 回车
    Enter passphrase (empty for no passphrase): //密码
    Enter same passphrase again: //密码
    

    结果:

    Your identification has been saved in /Users/mouMiFan/.ssh/id_rsa.
    Your public key has been saved in /Users/mouMiFan/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:OkZCZO3AEOTsBILDqS/RZQhmr/YW2KVMExtdFOHmZh0 your_email@example.com
    The key's randomart image is:
    +---[RSA 2048]----+
    |*==B+.o=o        |
    |**ooO.o          |
    |.o+B.+ o E       |
    |ooB.+ + . .      |
    | *.=. .+S.       |
    |o o .oo.         |
    | . o  +          |
    |  .  . .         |
    |                 |
    +----[SHA256]-----+
    

    在~/.ssh 文件夹中便生成了文件: id_rsa 文件是私有密钥,id_rsa.pub 是公开密钥。

  3. 查看公钥

    cat ~/.ssh/id_rsa.pub
    
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4y3M40TOWuHhEraguOtunMtzywSre2ZcsvFUIAQ7DDPkp+pX4Su0RpYaqIvKm4JHy2f3+IsnlbThAJQkbJ4UC8YufHsk7h+bvjnb7P4lQGvbgHTu4zt2xrOBc3XiJrO+bCJLHwzdaVR8qE+uzwEaSE5b+VqH4xZt58yOBV4e2/fCBvlSnOqwuCMdaRNi2HnB1C+TEoEWFfJQxrgFWW1eEwbfwA/g4bkL9jNz8VVPnYRI6kZiVHIA6SLHmVzDdVCy0WgqKFUIkUVPSviahWdFV73IyMIvGt+s1FtE90iKIVH4SBIUrhhbxgHgX6Vgpv6qo2o1QJUqMW23cGwUfALrL your_email@example.com
    
  4. 提交到gitHub

    打开 https://github.com/settings/ssh,点击New SSH Key按钮,粘贴上面的公钥保持即可

posted @ 2016-09-29 22:17  阿克西斯教成员污米饭  阅读(3421)  评论(0编辑  收藏  举报