Git SSH Key生成,配置到GitHub 并测试

//本环境为os下

//首先是查看本机安装git版本

yangliu$ git --version

    git version 2.17.0

//git目录

yangliu$ which git

    /usr/local/bin/git

//生成git用户名和邮箱

 yangliu$ git config --global user.name "renyu"                    //里面是自己的用户名

 yangliu$ git config --global user.email "ren**@163.com"           //里面是自己的邮箱

//查看是否已经有密钥,我这里之前没有,有的话用就可以咯

yangliu$ cd ~/.ssh

    -bash: cd: /Users/yangliu/.ssh: No such file or directory

//生成根,输入下面的命令后 三个回车,其中有输入密码,这里有一步就是密码为空

yangliu$ ssh-keygen -t rsa -C "ren****@163.com"

    Generating public/private rsa key pair.

    Enter file in which to save the key (/Users/yangliu/.ssh/id_rsa):         //生成的id_rsa公钥

    Created directory '/Users/yangliu/.ssh'.

    Enter passphrase (empty for no passphrase): 

    Enter same passphrase again: 

    Your identification has been saved in /Users/yangliu/.ssh/id_rsa.

    Your public key has been saved in /Users/yangliu/.ssh/id_rsa.pub.//生成的公钥地址

    The key fingerprint is:

    SHA256:******* ren*****@163.com

    The key's randomart image is:

    +---[RSA 2048]----+

    |        .       .|

    |         o .   o.|

    |          o . o.o|

    |       . o .o .o.|

    |      + S oo =o  |

    |     . o   .X+ o |

    |         . Bo.*o+|

    |        . *.O=+o=|

    |       E o.**B oo|

    +----[SHA256]-----+

//查看生成的公钥

yangliu$ cd /Users/yangliu/.ssh/

yangliu$ cat id_rsa.pub

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHqIyXu2BcSU3OYWdx3rLTYe3UlX03BOrSjs91TYCXh****************************************     renyu1404@163.com


//测试github

yangliu$ ssh git@github.com

    The authenticity of host 'github.com (13.250.177.223)' can't be established.

    RSA key fingerprint is SHA256:************.

    Are you sure you want to continue connecting (yes/no)? yes//输入

    Warning: Permanently added 'github.com,13.250.*.*' (RSA) to the list of known hosts.

    PTY allocation request failed on channel 0

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

    Connection to github.com closed.


可以把生成的公钥放到github上就可以上传到他那里啦 ,也可以添加到你们公司的authorized_keys上。



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

任玉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值