git:fatal:无法从远程存储库中读取

use*_*629 311 git

我正试图用http://danielmiessler.com/study/git/#website设置git 来管理我的网站.

我已经完成了说明的最后一步:git push website + master:refs/heads/master

我正在使用win7中的git ming32命令行

$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

这里的一个问题可能是程序正在寻找Bill@***.com.当我通过ssh连接到我的网站时,我有一个不同的用户名(让我们说'abc').所以也许这应该是abc@***.com.如果是这样,我不知道如何改变这个或者我是否可以推动别名

小智 135

您的ssh密钥很可能已从ssh代理中删除

ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

其中id_rsa是与git repo关联的ssh密钥

  • 我收到“无法打开与您的身份验证代理的连接。”。 (10认同)
  • 这对我有用!我花了很长时间尝试将〜/ .ssh / config文件配置为对不同的主机使用不同的密钥,以为这个文件是问题所在。最后,它必须一直在为正确的主机使​​用正确的密钥,但是该密钥已被“删除”。所以`ssh-add〜/ .ssh / theKeyInQuestion`使我重新启动并使用此存储库运行,不知道已删除密钥,甚至不知道“删除”是什么意思,但至少我能够再次进行身份验证。即使经过数月的身份验证问题,SSH仍然是我的一个谜。ssh代理问题是您还需要注意的一件事! (3认同)
  • 这为我解决了这个问题,我不明白为什么..它曾经有效,但突然不行了,是否有一个过程可以从代理中删除密钥,它会意外发生吗? (3认同)
  • 在 MacBook 中我使用 `ssh-add -k ~/.ssh/id_rsa` (2认同)
  • @DanDascalescu 首先尝试使用 `eval \`ssh-agent -s\`` 启动 ssh-agent (2认同)

rob*_*off 119

您可以指定SSH应作为远程URL的一部分发送到远程系统的用户名.@在远程主机名之前输入用户名,后跟an .

git remote set-url website abc@***.com:path/to/repo
Run Code Online (Sandbox Code Playgroud)

  • 编辑具有远程url参数的文件`.git/config` (12认同)
  • 对于Github,您总是使用用户名`git`.示例:`git@github.com:mayoff/uiimage-from-animated-gif.git`Github通过查看您发送的SSH密钥来确定您的身份. (7认同)
  • ps,有没有办法添加密码,所以我不必一直输入密码? (3认同)

Tom*_*art 112

确保你有正确的网址 .git/config

url = git@github.com:username/repo.git
Run Code Online (Sandbox Code Playgroud)

如果这是你的第一次推动,你需要设置正确的上游

$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)

您可以通过以下方式检查使用的密钥:

$ ssh -vvv git@github.com
Run Code Online (Sandbox Code Playgroud)

回复应包含以下内容:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
...
You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)

此外,还可以为ssh定义规则~/.ssh/config,例如基于别名:

   Host github
      HostName github.com 
      User git
      IdentityFile "~/.ssh/id_rsa"

   Host git
      HostName github.com 
      User git
      IdentityFile "~/.ssh/some_other_id"
Run Code Online (Sandbox Code Playgroud)

您可以设置连接到不同的端口,为每个别名使用不同的用户名等.


Man*_*kar 106

我刚才面临同样的问题......

我的.git/config了

url = git@github.com:manishnakar/polymer-demo.git
Run Code Online (Sandbox Code Playgroud)

我换了它

url = https://github.com/manishnakar/polymer-demo.git 
Run Code Online (Sandbox Code Playgroud)

它现在有效:)

  • 这不是一个答案。它会更改您进行身份验证的协议。这不是 ssh 设置的解决方案,而是与 git 存储库对话的完全不同的方式 (48认同)
  • 怎么这不高排名?git @ github完全不适合我 (5认同)
  • 如果repo所有者没有设置`ssh`键,那么你可能会遇到这个问题.所示的修复是使用`https`,或让repo所有者设置`ssh` (3认同)
  • 这是正确的答案,它立即对我有用。 (2认同)

Sco*_*ner 22

尝试删除GIT_SSH环境变量unset GIT_SSH.这是我的问题的原因.


Bas*_*bin 13

这通常是由于SSH密钥与远程不匹配引起的.

解决方案:

  1. 转到终端并键入以下命令(Mac,Linux)替换为您的电子邮件ID.

    ssh-keygen -t rsa -C"you@email.com"

  2. 使用以下命令从单词ssh开始复制生成的密钥.

    cat~/.ssh/id_rsa.pub

  3. 将它粘贴到你的遥控器各自的github,bitbucket或gitlab中.
  4. 保存.


For*_*ver 13

我有一个错误的 Bitbucket ssh 私钥以及正确的 ssh 代理。

首先删除所有键

ssh-add -D
Run Code Online (Sandbox Code Playgroud)

然后添加了正确的键。

ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)


小智 11

通过在终端上执行以下命令,确保ssh-agent正在运行:

eval $(ssh-agent -s)
Run Code Online (Sandbox Code Playgroud)

来源:Github文档


Shu*_*min 10

对我有用的非常简单的解决方案,请参见下文:-

问题
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
这也应该超时
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
Run Code Online (Sandbox Code Playgroud)
这可能有效
$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
覆盖 SSH 设置
$ vim ~/.ssh/config

# You can also manually open the file and copy/paste the section below
# Add section below to it
Host github.com
  Hostname ssh.github.com
  Port 443
Run Code Online (Sandbox Code Playgroud)
然后再试一次
$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.
Run Code Online (Sandbox Code Playgroud)
现在尝试克隆(应该可以)
$ git clone git@github.com:xxxxxx/xxxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.
Run Code Online (Sandbox Code Playgroud)

参考:此处 =>使用 HTTPS 和端口 443


小智 8

在做了一些研究之后我终于得到了解决方案,你已经为plink.exe路径声明了一个环境变量.因此,如果您删除该路径,请重新打开git bash并尝试通过SSH克隆它将起作用.

请参阅此链接

http://sourceforge.net/p/forge/site-support/2959/#204c


Pra*_*tel 8

我有同样的问题.

此错误表示您尚未指定代码将推送到的远程URL位置.

您可以通过2种(主要)方式设置远程URL:

  1. 通过在Git Bash上执行命令指定远程URL.

    • 导航到您的项目目录

    • 打开Git Bash

    • 执行命令:

      • git remote set-url origin <https://abc.xyz/USERNAME/REPOSITORY.git>
  2. 在配置文件中提及远程URL

    • 导航到您的项目目录

    • 移至.git文件夹

    • 在文本编辑器中打开配置文件

    • 复制并粘贴下面的行

      • [remote "origin"] url = https://abc.xyz/USERNAME/REPOSITORY.git fetch = +refs/heads/*:refs/remotes/origin/*

有关更多详细信息,请访问此链接.


kip*_*ip2 7

另一种解决方法:

有时这会发生在我身上,因为网络问题。我不完全理解根本问题,但切换到不同的子网或使用 VPN 可以解决它


小智 6

我有同样的错误.解决方案如下:我已经纠正了我的网址.git/config.刚刚从HTTPS克隆URL复制了它.那将是这样的:

url = https://github.com/*your*git*name*/*your*git*app*.git
Run Code Online (Sandbox Code Playgroud)

有效.


小智 5

如果在“git push origin master”命令之后你看到错误“无法从远程存储库读取”然后试试这个

1.ssh-keygen -t rsa -b 4096 -C "youremail"
2.eval $(ssh-agent -s)
3.ssh-add ~/.ssh/id_rsa
4.clip < ~/.ssh/id_rsa.pub(it copies the ssh key that has got generated)
5.then go to your remote repository on github and goto settings-> SSH and GPG keys ->new SSH key ->enter any title and paste the copied SSH key and save it
6. now give git push origin master 
Run Code Online (Sandbox Code Playgroud)


off*_*dal 5

我面临着同样的问题。所以这就是我解决同样问题的方法

步骤1:

创建一个新的 ssh 密钥:-

ssh-keygen -t ed25519 -C "your_email@example.com"
Run Code Online (Sandbox Code Playgroud)

第2步:

将 ssh 密钥复制到剪贴板上:-

pbcopy < ~/.ssh/id_ed25519.pub 
Run Code Online (Sandbox Code Playgroud)

步骤3:

现在将复制的 ssh 密钥粘贴到相应的 git 存储库

步骤 4: 在后台启动 ssh-agent。

$ eval "$(ssh-agent -s)"
> Agent pid 59566
Run Code Online (Sandbox Code Playgroud)

第 5 步: 现在尝试访问存储库

git clone git@github.com:username/repo-name.git
Run Code Online (Sandbox Code Playgroud)

第6步:

如果您仍然看到问题,请检查 ssh 配置文件

vim ~/.ssh/config
Run Code Online (Sandbox Code Playgroud)

内容应该是这样的

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519
Run Code Online (Sandbox Code Playgroud)

第7步:

将您的 SSH 私钥添加到 ssh-agent 并将您的密码存储在钥匙串中

ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Run Code Online (Sandbox Code Playgroud)

步骤8:

现在再试一次应该可以了

git clone git@github.com:username/repo-name.git
Run Code Online (Sandbox Code Playgroud)