<!DOCTYPE html><htmllang="zh-CN"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1,maximum-scale=2"><metaname="theme-color"content="#222"><metaname="generator"content="Hexo 4.2.0"><linkrel="apple-touch-icon"sizes="180x180"href="/images/apple-touch-icon-next.png"><linkrel="icon"type="image/png"sizes="32x32"href="/images/favicon-32x32-next.png"><linkrel="icon"type="image/png"sizes="16x16"href="/images/favicon-16x16-next.png"><linkrel="mask-icon"href="/images/logo.svg"color="#222"><linkrel="stylesheet"href="/css/main.css"><linkrel="stylesheet"href="/lib/font-awesome/css/all.min.css"><script id="hexo-configurations">varNexT=window.NexT||{},CONFIG={hostname:"alderaan.xyz",root:"/",scheme:"Gemini",version:"7.8.0",exturl:!1,sidebar:{position:"left",display:"post",padding:18,offset:12,onmobile:!1},copycode:{enable:!1,show_result:!1,style:null},back2top:{enable:!0,sidebar:!1,scrollpercent:!1},bookmark:{enable:!1,color:"#222",save:"auto"},fancybox:!1,mediumzoom:!1,lazyload:!1,pangu:!1,comments:{style:"tabs",active:null,storage:!0,lazyload:!1,nav:null},algolia:{hits:{per_page:10},labels:{input_placeholder:"Search for Posts",hits_empty:"We didn't find any results for the search: ${query}",hits_stats:"${hits} results found in ${time} ms"}},localsearch:{enable:!1,trigger:"auto",top_n_per_article:1,unescape:!1,preload:!1},motion:{enable:!0,async:!1,transition:{post_block:"fadeIn",post_header:"slideDownIn",post_body:"slideDownIn",coll_header:"slideLeftIn",sidebar:"slideUpIn"}}}</script><metaname="description"content="概述 今天在用Hexo发布博客文章时,遇到上传Github失败问题,主要提示为 12345Connection reset by 52.74.223.119fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exi"><metaproperty="og:type"content="article"><metaproperty="og:title"content="ssh -T git@github.com Connection reset by XXX port 22"><metaproperty="og:url"content="https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/index.html"><metaproperty="og:site_name"content="Alderaan的博客"><metaproperty="og:description"content="概述 今天在用Hexo发布博客文章时,遇到上传Github失败问题,主要提示为 12345Connection reset by 52.74.223.119fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exi"><metaproperty="og:locale"content="zh_CN"><metaproperty="article:published_time"content="2020-05-07T05:34:09.000Z"><metaproperty="article:modified_time"content="2020-05-07T06:18:27.046Z"><metaproperty="article:author"content="Alderaan"><metaproperty="article:tag"content="Github"><metaproperty="article:tag"content="SSH"><metaname="twitter:card"content="summary"><linkrel="canonical"href="https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/"><script id="page-configurations">CONFIG.page={sidebar:"",isHome:!1,isPost:!0,lang:"zh-CN"}</script><title>ssh -T git@github.com Connection reset by XXX port 22 | Alderaan的博客</title><noscript><style>.sidebar-inner,.use-motion.brand,.use-motion.collection-header,.use-motion.comments,.use-motion.menu-item,.use-motion.pagination,.use-motion.post-block,.use-motion.post-body,.use-motion.post-header{opacity:initial}.use-motion.site-subtitle,.use-motion.site-title{opacity:initial;top:initial}.use-motion.logo-line-beforei{left:initial}.use-motion.logo-line-afteri{right:initial}</style></noscript><linkrel="alternate"href="/atom.xml"title="Alderaan的博客"type="application/atom+xml"></head><bodyitemscopeitemtype="http://schema.org/WebPage"><divclass="container use-motion"><divclass="headband"></div><headerclass="header"itemscopeitemtype="http://schema.org/WPHeader"><divclass="header-inner"><divclass="site-brand-container"><divclass="site-nav-toggle"><divclass="toggle"aria-label="切换导航栏"><spanclass="toggle-line toggle-line-first"></span><spanclass="toggle-line toggle-line-middle"></span><spanclass="toggle-line toggle-line-last"></span></div></div><divclass="site-meta"><ahref="/"class="brand"rel="start"><spanclass="logo-line-before"><i></i></span><h1class="site-title">Alderaan的博客</h1><spanclass="logo-line-after"><i></i></span></a></div><divclass="site-nav-right"><divclass="toggle popup-trigger"></div></div></div><navclass="site-nav"><ulid="menu"class="main-menu menu"><liclass="menu-item menu-item-home"><ahref="/"rel="section"><iclass="fa fa-home fa-fw"></i> 首页</a></li><liclass="menu-item menu-item-about"><ahref="/about/"rel="section"><iclass="fa fa-user fa-fw"></i> 关于</a></li><liclass="menu-item menu-item-tags"><ahref="/tags/"rel="section"><iclass="fa fa-tags fa-fw"></i> 标签</a></li><liclass="menu-item menu-item-categories"><ahref="/categories/"rel="section"><iclass="fa fa-th fa-fw"></i> 分类</a></li><liclass="menu-item menu-item-archives"><ahref="/archives/"rel="section"><iclass="fa fa-archive fa-fw"></i> 归档</a></li></ul></nav></div></header><divclass="back-to-top"><iclass="fa fa-arrow-up"></i><span>0%</span></div><mainclass="main"><divclass="main-inner"><divclass="content-wrap"><divclass="content post posts-expand"><articleitemscopeitemtype="http://schema.org/Article"class="post-block"lang="zh-CN"><linkitemprop="mainEntityOfPage"href="https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/"><spanhiddenitemprop="author"itemscopeitemtype="http://schema.org/Person"><metaitemprop="image"content="/images/avatar.jpg"><metaitemprop="name"content="Alderaan"><metaitemprop="description"content=""></span><spanhiddenitemprop="publisher"itemscopeitemtype="http://schema.org/Organization"><metaitemprop="name"content="Alderaan的博客"></span><headerclass="post-header"><h1class="post-title"itemprop="name headline"> ssh -T git@github.com Connection reset by XXX port 22</h1><divclass="post-meta"><spanclass="post-meta-item"><spanclass="post-meta-item-icon"><iclass="far fa-calendar"></i></span><spanclass="post-meta-item-text">发表于</span><timetitle="创建时间:2020-05-07 13:34:09 / 修改时间:14:18:27"itemprop="dateCreated datePublished"datetime="2020-05-07T13:34:09+08:00">2020-05-07</time></span><spanclass="post-meta-item"><spanclass="post-meta-item-icon"><iclass="far fa-folder"></i></span><spanclass="post-meta-item-text">分类于</span><spanitemprop="about"itemscopeitemtype="http://schema.org/Thing"><ahref="/categories/Github/"itemprop="url"rel="index"><spanitemprop="name">Github</span></a></span></span><spanclass="post-meta-item"title="阅读次数"id="busuanzi_container_page_pv"style="display:none"><spanclass="post-meta-item-icon"><iclass="fa fa-eye"></i></span><spanclass="post-meta-item-text">阅读次数:</span><spanid="busuanzi_value_page_pv"></span></span></div></header><divclass="post-body"itemprop="articleBody"><h2id="概述"><ahref="#概述"class="headerlink"title="概述"></a>概述</h2><p> 今天在用<strong>Hexo</strong>发布博客文章时,遇到上传<strong>Github</strong>失败问题,主要提示为</p><figureclass="highlight bash"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br><spanclass="line">2</span><br><spanclass="line">3</span><br><spanclass="line">4</span><br><spanclass="line">5</span><br></pre></td><tdclass="code"><pre><spanclass="line">Connection reset by 52.74.223.119</span><br><spanclass="line">fatal: Could not <spanclass="built_in">read</span> from remote repository.</span><br><spanclass="line"></span><br><spanclass="line">Please make sure you have the correct access rights</span><br><spanclass="line">and the repository exists.</span><br></pre></td></tr></table></figure><aid="more"></a><h2id="问题发现"><ahref="#问题发现"class="headerlink"title="问题发现"></a>问题发现</h2><p> 由于已经在<code>Git bash</code>中配置过SSH免密访问,且已正常使用过也没有进行修改,所以排除SSH key配置问题。怀疑是无法连接到<code>github.com</code>,尝试执行<code>ssh -T git@github.com</code>得到如下结果:</p><figureclass="highlight bash"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br><spanclass="line">2</span><br></pre></td><tdclass="code"><pre><spanclass="line">$ ssh -T git@github.com</span><br><spanclass="line">Connection reset by 52.74.223.119 port 22</span><br></pre></td></tr></table></figure><p> 竟然真的无法SSH连接到github.com???增加<code>-v</code>选项查看一下详细信息,反馈如下:</p><figureclass="highlight bash"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br><spanclass="line">2</span><br><spanclass="line">3</span><br><spanclass="line">4</span><br><spanclass="line">5</span><br><spanclass="line">6</span><br><spanclass="line">7</span><br><spanclass="line">8</span><br><spanclass="line">9</span><br><spanclass="line">10</span><br><spanclass="line">11</span><br><spanclass="line">12</span><br><spanclass="line">13</span><br><spanclass="line">14</span><br><spanclass="line">15</span><br><spanclass="line">16</span><br><spanclass="line">17</span><br><spanclass="line">18</span><br><spanclass="line">19</span><br><spanclass="line">20</span><br><spanclass="line">21</span><br><spanclass="line">22</span><br></pre></td><tdclass="code"><pre><spanclass="line">$ ssh -T -v git@github.com</span><br><spanclass="line">OpenSSH_8.0p1, OpenSSL 1.1.1c 28 May 2019</span><br><spanclass="line">debug1: Reading configuration data /c/Users/Alder/.ssh/config</span><br><spanclass="line">debug1: Reading configuration data /etc/ssh/ssh_config</span><br><spanclass="line">debug1: Connecting to github.com [52.74.223.119] port 22.</span><br><spanclass="line">debug1: Connection established.</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_rsa <spanclass="built_in">type</span> 0</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_rsa-cert <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_dsa <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_dsa-cert <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_ecdsa <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_ecdsa-cert <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_ed25519 <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_ed25519-cert <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_xmss <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: identity file /c/Users/Alder/.ssh/id_xmss-cert <spanclass="built_in">type</span> -1</span><br><spanclass="line">debug1: Local version string SSH-2.0-OpenSSH_8.0</span><br><spanclass="line">debug1: Remote protocol version 2.0, remote software version babeld-d45c1532</span><br><spanclass="line">debug1: no match: babeld-d45c1532</span><br><spanclass="line">debug1: Authenticating to github.com:22 as <spanclass="string">'git'</span></span><br><spanclass="line">debug1: SSH2_MSG_KEXINIT sent</span><br><spanclass="line">Connection reset by 52.74.223.119 port 22</span><br></pre></td></tr></table></figure><h2id="问题解决"><ahref="#问题解决"class="headerlink"title="问题解决"></a>问题解决</h2><p> 在Windows系统下,打开控制面板->系统和安全->Windows Defender 防火墙->高级设置,选择入站规则,点击新建规则,选择端口,在特定本地端口写入22,连续选择下一步三次,输入一个名称(随意命名规则),点击完成,然后再执行命令得到如下格式结果:</p><figureclass="highlight bash"><table><tr><tdclass="gutter"><pre><spanclass="line">1</span><br><spanclass="line">2</span><br></pre></td><tdclass="code"><pre><spanclass="line">$ ssh -T git@github.com</span><br><spanclass="line">Hi XXX! You<spanclass="string">'ve successfully authenticated, but GitHub does not provide shell access.</span></span><br></pre></td></tr></table></figure><p> 再尝试发布<strong>Hexo</strong>博客到<strong>Github</strong>就可以正常上传了…暂时不知道这其中的原理,即使将刚添加的规则删除了,再打开新的<code>Git bash</code>窗口也不会出现Connection reset错误了。。。</p></div><div><ulclass="post-copyright"><liclass="post-copyright-author"><strong>本文作者:</strong> Alderaan</li><liclass="post-copyright-link"><strong>本文链接:</strong><ahref="https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/"title="ssh -T git@github.com Connection reset by XXX port 22">https://alderaan.xyz/2020/05/07/ssh-to-git-github-com-connection-reset/</a></li><liclass="post-copyright-license"><strong>版权声明:</strong> 本博客所有文章除特别声明外,均采用<ahref="https://creativecommons.org/licenses/by-nc-sa/4.0/"rel="noopener"target="_blank"><iclass="fab fa-fw fa-creative-commons"></i> BY-NC-SA</a> 许可协议。转载请注明出处!</li></ul></div><footerclass="post-footer"><divclass="post-tags"><ahref="/tags/Github/"rel="tag"><iclass="fa fa-tag"></i> Github</a><ahref="/tags/SSH/"rel="tag"><iclass="fa fa-tag"></i> SSH</a></div><divclass="post-nav"><divclass="post-nav-item"><ahref="/2020/05/06/hexo-config/"rel="prev"title="Hexo博客Next主题美化"><iclass="fa fa-chevron-left"></i> Hexo博客Next主题美化</a></div><divclass="post-nav-item"></div></div></footer></article></div><script>