zoukankan      html  css  js  c++  java
  • github平台部署sshkey

    不要细看,参考其逻辑即可,官方给的方法不是rsa,是

    1. 

    ssh-keygen -t ed25519 -C "你的github账号对应的邮箱" -f id_ed25519_github 

    其中-f id_ed25519_github  是指定保存到本地的名称,避免和其他git平台冲突

    2. 

    pbcopy < ~/.ssh/id_ed25519_github.pub 

    拷贝pubkey,填写到 github上的 sshkey,详见:https://github.com/settings/keys

     

    3. 

     ssh-agent -s   

    4. 

    ssh-add ~/.ssh/id_ed25519_github 

    5. 

     ssh -T git@github.com 

     

    三四五步骤是参考下文

    博主在github上下载tiny face的的源代码的时候,遇到git clone命令为:git clone --recursive git@github.com:peiyunh/tiny.git

      而当我在ternimal下执行这条语句的时候,出现错误:

      Permissiondenied (publickey).

      fatal:Could not read from remote repository.

      Pleasemake sure you have the correct access rights

      and the repository exists.

      但是其实执行命令:git clone git@github.com:peiyunh/tiny.git 是没有问题的(不加--recursive参数),于是百度了一番,我理解的是原因是由于你在本地(或者服务器上)没有生成ssh key,你可以在ternimal下执行:

      cd ~/.ssh ls来查看是否有文件id_rsa以及文件id_rsa.pub,如下图所示:(我的已经生成了,所以我ls后会显示。)

      

      下面记录下解决办法:

      1.首先,如果你没有ssh key的话,在ternimal下输入命令:ssh-keygen -t rsa -C "youremail@example.com", youremail@example.com改为自己的邮箱即可,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)

      

      2.然后再ternimal下执行命令:

      ssh -v git@github.com

      最后两句会出现:

      No more authentication methods to try.  

      Permission denied (publickey).

      3.这时候再在ternimal下输入:

      ssh-agent -s

      然后会提示类似的信息:

      SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK;  

      SSH_AGENT_PID=13144; export SSH_AGENT_PID;  

      echo Agent pid 13144;

      4.接着再输入:

      ssh-add ~/.ssh/id_rsa

      这时候应该会提示:

      Identity added: ...(这里是一些ssh key文件路径的信息)

      (注意)如果出现错误提示:

      Could not open a connection to your authentication agent.

      请执行命令:eval `ssh-agent -s`后继续执行命令 ssh-add ~/.ssh/id_rsa,这时候一般没问题啦。

      5.打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。

      6.最后一步,验证Key

      在ternimal下输入命令:

      ssh -T git@github.com

      提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell  access.

      这时候你的问题就解决啦,可以使用命令 git clone --recursive git@github.com:peiyunh/tiny.git 去下载你的代码啦。

  • 相关阅读:
    cookie的路径
    cookie的生命
    cookie详解
    cookie简介&用途
    编码
    请求转发和重定向的区别
    request:域
    request:请求转发,请求包含
    常用的html语法
    request:获取请求的URL
  • 原文地址:https://www.cnblogs.com/duanweishi/p/15057325.html
Copyright © 2011-2022 走看看