• (诊断)为GitHub添加SSH key时出现“Could not open a connection to your authentication agent”错误的应对方案。


      在为windows 环境下的github账户添加SSH key时,需要在Git Bash执行如下命令:

    第一步:检查已有的SSH keys

    $ ls -al ~/.ssh

    第二步:生成新的SSH key

    $ ssh-keygen -t rsa -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    # Generating public/private rsa key pair.
    # Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    # Enter same passphrase again: [Type passphrase again]

    接着会得到如下的提示:

    Your identification has been saved in /c/Users/you/.ssh/id_rsa.
    # Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
    # The key fingerprint is:
    # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

    然后将这个新的key添加到ssh-agent中:

    $ ssh-agent -s
    # Agent pid 59566
    $ ssh-add ~/.ssh/id_rsa

    *注: 如果执行 ssh-add 时显示错误 Could not open a connection to your authentication agent. 那么执行

    eval `ssh-agent -s`

    后重新执行 ssh-add 那条命令即可。

    第三步:将SSH key添加到你的GitHub账户

    首先将公钥复制到粘贴板:

    $ clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard

    或者使用文本编辑工具也能解决。

    然后在github的账户页的右上角,点击配置(settings, 齿轮图形),在sidebar中点击“SSH keys”,接着点击“Add SSH key”,在"title"栏输入一个自己喜欢的标题,“key”栏中粘贴刚刚复制的公钥内容,最后点击“Add key”按钮。

    第四步:检查SSH key是否成功设置

    $ ssh -T git@github.com
    # Attempts to ssh to GitHub

    可能会看到如下的警告:

    The authenticity of host 'github.com (207.97.227.239)' can't be established.
    # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    # Are you sure you want to continue connecting (yes/no)?

    输入“yes”,如果得到下面的结果,说明你的设置是成功的!

    Hi username! You've successfully authenticated, but GitHub does not
    # provide shell access.
  • 相关阅读:
    Linux Kernel 'b43'无线驱动本地特权提升漏洞
    Linux Kernel “dispatch_discard_io()”RO Disk Manipulation安全绕过漏洞
    Linux kernel ‘fill_event_metadata’函数资源管理错误漏洞
    Linux kernel ‘b43_request_firmware’函数格式化字符串漏洞
    phpcms 2007 onunload.inc.php update SQL注入漏洞
    出差到天津的计划
    Auguries of Innocence
    做一个东西要多久
    Wise Installation 9 的一个容易忽视的选项
    天津行总结路在嘴底下
  • 原文地址:https://www.cnblogs.com/Security-Darren/p/4106328.html
Copyright © 2020-2023  润新知