【问题标题】:Warning: Permanently added the RSA host key for IP address警告:为 IP 地址永久添加 RSA 主机密钥
【发布时间】:2022-03-08 15:27:24
【问题描述】:

当我从 Github 执行 pull 时,我收到了这条警告消息。

    MYPC:/Rails$ git pull origin master
    Warning: Permanently added the RSA host key for IP address '#{Some IP address}' to the list of known hosts.
    From github.com:Example/Demo
     * branch            master     -> FETCH_HEAD
    Already up-to-date.

我只想知道它添加到已知主机的 IP 地址。

【问题讨论】:

    标签: git github ssh


    【解决方案1】:

    如果您通过 SSH 协议访问存储库,则每次您的客户端连接到 github.com 的新 IP 地址时,您都会收到一条警告消息。只要警告中的 IP 地址在 IP 地址范围内,您就不必担心。具体来说,这次添加的新地址在192.30.252.0 to 192.30.255.255的范围内。警告消息如下所示:

    Warning: Permanently added the RSA host key for IP address '$IP' to the list of 
    

    https://github.com/blog/1606-ip-address-changes

    【讨论】:

    • 192.30.252.0 to 192.30.255.255
    • @Ashwini - 是的 - 这不是你机器的 IP 地址 - 它是你正在连接的 github 机器的 IP 地址。
    • 谢谢 :) Rajarshi & Taryn
    【解决方案2】:

    IP 地址又变了。

    github 在此处发布使用的 IP 地址列表,以便您可以对照 github 的列表检查消息中的 IP 地址:

    https://help.github.com/articles/about-github-s-ip-addresses/

    或者更准确地说:

    https://api.github.com/meta

    看起来像这样(当我写这个答案时!):

    verifiable_password_authentication  true
    github_services_sha "4159703d573ee6f602e304ed25b5862463a2c73d"
    hooks   
    0   "192.30.252.0/22"
    1   "185.199.108.0/22"
    git 
    0   "192.30.252.0/22"
    1   "185.199.108.0/22"
    2   "18.195.85.27/32"
    3   "18.194.104.89/32"
    4   "35.159.8.160/32"
    pages   
    0   "192.30.252.153/32"
    1   "192.30.252.154/32"
    importer    
    0   "54.87.5.173"
    1   "54.166.52.62"
    2   "23.20.92.3"
    

    如果您不确定您的 IP 地址是否包含在上述列表中,请使用 CIDR 计算器(如 http://www.subnet-calculator.com/cidr.php)来显示有效的 IP 范围。

    E. G。对于140.82.112.0/20,IP 范围是140.82.112.0 - 140.82.127.255

    【讨论】:

    • 只有我看到 140.82.118.4 吗?
    • 如果在我的回答中添加了有关 CIDR IP 地址格式的说明。我认为您的 IP 地址到今天为止还可以!
    • 谢谢!没错,140.82.112.0/20 已添加到 meta. :)
    【解决方案3】:

    这是我为解决问题而采取的步骤,您也可以尝试

    1. 打开 git bash 终端
    2. 输入ssh-keygen并回车
    3. 然后终端将要求输入文件名以保存 rsa 密钥。您可以按 Enter not
      - 输入任何内容
    4. 之后终端也会询问其他信息。无需输入任何内容,只需按 Enter 通过完成每个步骤,将在上述文件中生成一个 rsa 密钥。
    5. 转到C:\Users\<username>\.ssh并在记事本中打开一个名为id_rsa.pub的文件并复制密钥
    6. 然后转到您的 github 帐户 Settings 并选择选项 SSH and GPS keys
    7. 如果您尝试通过git push origin master 推送,请创建一个带有标题的新 ssh 密钥和您刚刚复制的密钥(您刚刚生成)点击保存,希望您不会收到任何错误

    【讨论】:

    • 感谢它的工作,如果你使用的是 mac 复制 id_rsa.pub 代码它工作
    【解决方案4】:

    发件人:https://github.blog/changelog/2019-04-09-webhooks-ip-changes/

    2019 年 4 月 9 日

    Webhooks IP 更改

    我们用来发送 webhook 的 IP 地址正在扩大以涵盖更大的范围。

    我们正在将140.82.112.0/20 中的 IP 添加到来自192.30.252.0/22 的当前池中。

    Learn more about GitHub’s IP addresses

    【讨论】:

      【解决方案5】:

      我有类似的问题。在用户单击克隆或下载按钮后的 git 站点中,在复制克隆的 url 时,有 2 个选项可以选择 ssh 和 https。我选择了 https url 进行克隆,它工作正常。

      【讨论】:

        【解决方案6】:

        您可以通过 ~/.ssh/config 文件中的条目删除 github.com 的警告:

        Host github.com
            CheckHostIP no
        

        来自 ssh_config 手册页:

        检查主机IP

        如果此标志设置为“是”,ssh(1) 将另外 检查 known_hosts 文件中的主机 IP 地址。这允许 ssh 检测主机密钥是否由于 DNS 欺骗而更改。如果设置了选项 为 ''no'',检查将不被执行。默认值为“是”。

        因此,将标志设置为“否”将禁止检查主机 IP,并允许主机 (github.com) 的任何 IP,无论它多久更改一次。

        【讨论】:

          【解决方案7】:

          例如ip 192.30.253.112 警告:

          $ git clone git@github.com:EXAMPLE.git
          Cloning into 'EXAMPLE'...
          Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
          remote: Enumerating objects: 135, done.
          remote: Total 135 (delta 0), reused 0 (delta 0), pack-reused 135
          Receiving objects: 100% (135/135), 9.49 MiB | 2.46 MiB/s, done.
          Resolving deltas: 100% (40/40), done.
          

          如果你是nslookup github url,那就是ip:

          $ nslookup github.com
          Server:         127.0.0.53
          Address:        127.0.0.53#53
          
          Non-authoritative answer:
          Name:   github.com
          Address: 192.30.253.112
          Name:   github.com
          Address: 192.30.253.113
          
          $ 
          

          【讨论】:

            【解决方案8】:

            克隆时,您可能会在下拉列表中使用 SSH。改成 Https 然后克隆。

            【讨论】:

              【解决方案9】:

              您可以通过编辑文件~/.ssh/known_hosts 来粗暴地删除警告,并删除所有与IP 地址关联的密钥相同的行。

              例如,如果您有 “警告:将 IP 地址 '140.82.114.4' 的 RSA 主机密钥永久添加到已知主机列表中。”,打开文件 ~/.ssh/known_hosts 并删除以下行:

              ...
              140.82.114.3 ssh-rsa AAAAB3NzaC1y...
              140.82.114.4 ssh-rsa AAAAB3NzaC1y...
              ...
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2019-06-26
                • 2018-03-21
                • 2016-11-11
                • 2012-03-07
                • 1970-01-01
                • 2011-11-05
                • 1970-01-01
                • 2019-12-30
                相关资源
                最近更新 更多