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

我已经到了指令的最后一步: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.

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


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

git remote set-url website abc@***.com:path/to/repo

在你的。git/config文件中

[remote "YOUR_APP_NAME"]
    url = git@heroku.com:YOUR_APP_NAME.git
    fetch = +refs/heads/*:refs/remotes/YOUR_APP_NAME/*

并简单地

git push YOUR_APP_NAME master:master 

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

请参阅此连结

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


确保你在.git/config中有正确的url

url = git@github.com:username/repo.git

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

$ git push -u origin master

你可以检查哪个键被使用:

$ ssh -vvv git@github.com

回复应该包含如下内容:

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

也可以在~/中为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"

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


尝试使用未设置的GIT_SSH删除GIT_SSH环境变量。这就是我的问题所在。


对于那些有此问题的私人远程回购。确保你在远程服务器上接受了Xcode协议:我们花了几周时间才找到这个解决方案

从命令行使用这个命令:sudo xcodebuild -license


我也犯了同样的错误。 解决方案如下: 我已经在。git/config中更正了我的url。 刚刚从HTTPS克隆URL复制。大概是这样的:

url = https://github.com/*your*git*name*/*your*git*app*.git

它工作。


我只是想补充一下这个问题。我有Git设置使用PLink和Pageant进行身份验证,我也得到了错误FATAL error: Disconnected:不支持可用的身份验证方法(服务器发送:publickey)。我已经打开了选美,但错误仍然显示。这个问题?我没有在Pageant中加载私钥(要添加密钥,请遵循以下说明)。就是这么简单。


我只是想分享我找到了一个简单的解决方法:

拒绝访问。 无法从远程存储库读取。 请确保您拥有正确的访问权限 并且存储库存在。

从gitlab注销,然后重新登录。这些问题应该得到解决。


另一个解决方案:

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


就我而言,我在办公室使用的是公司网络(没有互联网连接)。为了从github拉代码,我在gitbash中设置了https代理,然后使用https而不是ssh来拉代码,它工作得很好。然而,当涉及到推送代码时,https代理将不起作用。因此,切换到Internet网络(有Internet连接)或设置ssh代理可以解决这个问题。


这通常是由于SSH密钥与远程不匹配造成的。

解决方案:

转到终端,输入以下命令(Mac, Linux)替换为您的电子邮件id。 ssh -t rsa -C "you@email.com" 从word ssh开始,使用以下命令复制生成的密钥。 猫~ / . ssh / id_rsa . pub 粘贴在github, bitbucket或gitlab各自的远程。 保存它。


在使用putty/pageant时,请确保您没有忘记向pageant添加正确的SSH密钥,否则将出现此错误。咄


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

eval $(ssh-agent -s)

来源:Github文档


我之前也遇到过同样的问题…

我的.git/config有

url = git@github.com:manishnakar/polymer-demo.git

我把它换成了

url = https://github.com/manishnakar/polymer-demo.git 

现在它工作了:)


在我的情况下,它是postBuffer..

git config --global http.postBuffer 524288000

参考阅读:https://gist.github.com/marcusoftnet/1177936


实际上,我尝试了很多方法让它在Win7上工作,因为将SSH exectun从本机更改为build-it和向后更改,同样的错误。 偶然,我在“。”中将其更改为HTTPS。Git /config"文件如下:

[remote "origin"]
        url = https://github.com/user_name/repository_name.git
        fetch = +refs/heads/*:refs/remotes/origin/*

最终成功了。所以也许对你也有用。


git branch——set-upstream-to=origin/(分支名)


如果您仍然得到相同的错误,请确保在git设置->ssh选项卡->ssh client to use设置为openSSH


在我的情况下,我使用ssh密钥与密码验证与github。我没有在Windows中正确地设置pageant(只有在cygwin中)。缺少的步骤是将git_ssh环境变量指向plink.exe。此外,你需要得到github.com到plink known_hosts。

   plink github.com
   y
   <then ctrl-c>

希望这能有所帮助!

我当然希望intellij能给我一个更有用的错误,或者让我输入ssh密钥密码。


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

ssh-add ~/.ssh/id_rsa

哪里id_rsa是与git repo相关联的SSH密钥

更新

您可能会得到无法打开到您的身份验证代理的连接。错误,解决您需要首先启动代理的问题:

eval `ssh-agent -s`

我也犯了同样的错误,这让我得到了这个没有帮助的答案。 我试图创建一个新的“裸”存储库,第一次使用以下命令跟踪到NTFS位置:

cd myrepository
git init --bare \\myserver.mycompany.local\myrepository.git
git init
git status
git add .
git status
git commit -m "Initial Commit"
git remote add origin \\myserver.mycompany.local\myrepository.git
git push -u origin master
git status

我的问题原来是在NTFS位置中使用后斜杠而不是前斜杠,当试图添加原点来设置(新的)跟踪上游分支时。

我必须删除原点使用:

git remote rm origin

然后使用预期的正斜杠再次添加原点

git remote add origin //myserver.mycompany.local/myrepository.git

希望这对将来的人有所帮助。


我有同样的问题,一段时间后,我看到我在根用户(sudo -s)。希望这对某人有所帮助。


我换了电脑后出现了这个错误。我使用SourceTree和Bitbucket。

所以我必须在新电脑上添加SourceTree生成的SSH密钥,在比特桶设置>安全> SSH密钥,同时连接到我的网络比特桶帐户。


我也有同样的问题。

此错误意味着您没有指定代码将在其上进行推送的远程URL位置。

远程URL设置主要有2种方式:

通过在Git Bash上执行命令指定远程URL。 导航到项目目录 打开Git Bash 执行命令: git remote set-url origin <https://abc.xyz/USERNAME/REPOSITORY.git> 在配置文件中直接提到远程URL 导航到项目目录 移动到。git文件夹 在文本编辑器中打开配置文件 复制并粘贴以下行 (远程“起源”) url = https://abc.xyz/USERNAME/REPOSITORY.git Fetch = +refs/heads/*:refs/remotes/origin/*

欲了解更多详细信息,请访问此链接。


根据我的经验,这个问题发生的原因之一是因为你的网络连接不稳定。


我也面临同样的问题;简单地,你可以在你的命令窗口运行这个:

Git远程添加origin https://your/repository/url


添加到“我有同样的问题和……”,我也在Windows中通过Ming32 (git bash) shell使用git。

在我的情况下,回购要求我输入密码,不使用SSH密钥,但它没有提示密码,只是说“致命:无法读取…”,尽管我可以SSH正常,使用plink和SSH,并设置了两个已知的主机密钥。

我尝试了这里和其他SOs的大部分建议。

最后我发现它在Powershell中工作得很好,但在git bash中不行,没有任何更改或更正。


user@server:/etc/nginx$ cat .git/config 
...
[remote "origin"]
    url = git@gitlab.com:user/.git
    fetch = +refs/heads/*:refs/remotes/origin/*
...

使用ssh代替https。 在git中使用ssh密钥(添加ssh密钥)。 如果您是root用户,请使用ssh密钥。


$ sudo ssh-keygen
$ cat /root/.ssh/id_rsa.pub 

$ git init
$ git add file
$ git commit -m "add first file"
$ git remote add origin git@gitlab.com:user/example.git 
$ git push -u origin master

I would recommend to check all remotes you have configured with git remote -v If you had your repo configured to a remote that was deleted you will receive this error message: fatal: Could not read from remote repository. Please make sure you have the correct access rightsand the repository exists. Even when trying to push or pull to an other (existing) remote. So if you have a remote that was deleted, you can remove with git remote remove name-of-remote-to-remove and after that you can push or pull to your existing remotes without problems.


如果在“git push origin master”命令后,你看到错误“could not read from remote repository”,然后试试这个

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 

我有一个完美的工作git,突然我得到了一个错误,当我试图推到master。我发现,这是因为存储库主机有问题。

如果你使用GitHub或Bitbucket,你可以很容易地检查状态

https://status.github.com/messages或https://status.bitbucket.org/


如果您使用Gitlab,则可能需要在尝试拉或推之前登录并接受Gitlab的新术语。


当我试图将代码从工作默认点推到工作git时,我得到了这个错误。 所以我采取了以下步骤:

去我的个人git账户,用默认设置创建了repo 在终端上,git远程添加origin git@github.com:/.git Git push——set-upstream origin master,确保origin是upstream,下一次提交只能使用Git push进行。

出于某种原因,没有其他方法适合我。希望这有助于使用2个或更多git帐户的人。


我通过重新启动终端解决了这个问题(打开一个新的窗口/选项卡)。

所以如果你真的不想/不需要理解潜在的问题,在深入挖掘之前,测试方法值得一试:)


我尝试了所有的方法,包括生成新的密钥,添加到GitHub帐户,编辑.ssh/config和.git/config。但它还是给出了同样的错误。 然后我尝试了命令,它确实工作成功。

ssh-agent bash -c 'ssh-add ~/.ssh/id_rsa; git clone git@github.com:username/repo.git'

我间歇性地遇到这个问题,大多数时候它不会给出错误消息。对我来说,解决方案是在我的LDAP服务器的IP地址改变之后正确地配置LDAP。

的/etc/gitlab/gitlab.LDAP的rb配置指向一个不存在的IP地址,因此更改主机以指向LDAP服务器的正确主机名解决了这个问题。

要诊断问题,使用gitlab-ctl tail命令来帮助您找到堆栈跟踪。对我来说,我找到了这个stacktrace:

==> /var/log/gitlab/gitlab-rails/production.log <==

Net::LDAP::Error (No route to host - connect(2) for 10.10.10.12:389):
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/net-ldap-0.16.0/lib/net/ldap/connection.rb:72:in `open_connection'
...

修改/etc/gitlab/gitlab.rb中的主机值

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main: 
     label: 'My LDAP'
     # this was an IP address
     # host: '10.10.10.12'
     host: 'internal-ldap-server' # this is the fix
     port: 389

在更改上面的配置文件之后,一定要重新配置gitlab

gitlab-ctl reconfigure

我在windows 10上使用gitbash时遇到了这个问题。我尝试了几种方法来解决这个问题,主要是:

重新创建我的ssh密钥并更新到bitbucket。没有帮助 打开调试使用这个,并发现我得到了“shell请求失败在通道0”,在这里询问 重启我的windows电脑

以上这些都没用。我最终为windows重新安装了Git,这只花了几分钟,与我所做的其他事情相比,它解决了问题!


我遇到这个问题是由于多次输入错误的密码。

所以我必须将MaxAuthTries更改为更大的数字:

在服务器端打开sshd_config:

vim  /etc/ssh/sshd_config

更改MaxAuthTries编号:

MaxAuthTries 100    # there I change to 100, you can change to a bigger than your current tries number

可能是网络问题。

尝试执行ssh -vvvT git@gitlab.com。如果服务器意外挂起,可能是网络连接有问题。

将以下代码放到~/.ssh/config中

IPQoS lowdelay throughput

我刚刚遇到了这个问题,并通过:git配置用户来解决它。电子邮件“youremail”。


更新: 根本原因可能是我的网络和代理不好。 我仍然不知道为什么会发生这种情况,但每次都有这个错误,这个命令工作!!


在我的情况下,我试图克隆与sudo。根据Github的文档,你不应该使用sudo与git克隆: https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey#should-the-sudo-command-be-used-with-git

我所做的是给当前用户编辑目录的权限(Debian 9):

chown myuser:root .

然后克隆没有sudo,它工作。


我在ssh代理中有一个错误的ssh私钥。

先删除所有键

ssh-add -D

然后加了正确的键。

ssh-add ~/.ssh/id_rsa

如果您设置了receievepack或uploadpack 在我的情况下,我得到的错误设置后,他们的错误

receivepack = powershell git receive-pack

在我的例子中。git/config

你可以删除他们的答案如下所示

https://stackoverflow.com/a/26207308/7668448

或者直接修改.git/config


有时你需要使用ssh:// scheme的完整URL:

ssh://git@yourhost:port/path/repo.git

或指定端口:

ssh://git@yourhost:port/path/repo.git

对我来说,这解决了问题。


Git需要使用HTTPS:

在终端中输入:

$ git remote set-url origin abc@***.com:path/to/httpURLRepo

然后提交:

$ git add .
$ git commit -m "This is the commit message"

遇到这种情况是因为我在中国有防火长城…

kex_exchange_identity:连接被远程主机关闭 无法从远程存储库读取。 请确保您拥有正确的访问权限和存储库 的存在。


对我来说,问题和答案就写在我面前。当天早些时候,我编辑了/etc/ssh/ssh_config文件并添加了一些密钥。这个错误说:

/etc/ssh/ssh_config: line 52: Bad configuration option: allowusers
/etc/ssh/ssh_config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.

我删除了allowusers键和它的值,一切都按照预期工作。


不是OP的问题,但如果你在一个GitHub组织/团队中工作,你可能没有对存储库的写权限。不幸的是,git没有显示更具体的权限错误。在我的例子中,我正在使用一个私有存储库,并被授予了“Triage”或“Read”访问权限。

有关每个权限级别的存储库访问的更多信息,请参阅GitHub文档。

在GitHub上更改这一点的链接是https://github.com/orgs/ORGANISATION_NAME/teams/TEAM_NAME/repositories,在那里您可以更改给予团队的权限。


2020年10月更新

在大多数情况下,当您有多个用户从同一个客户端系统访问同一个git服务器时,该时间git服务器将访问密钥与用户混淆,但当您发出命令时,它将使用默认用户。

ssh -T git@gitlab.com

看看哪些用户是你想要积极推动的用户

简单的解决方案是从git服务器中删除未使用的用户公钥。

然后试着去取或拉,推它会为我工作


我也遇到了同样的问题,通过更新到最新的git版本解决了这个问题


我的解决方法其实很简单。我只需要从这个问题“请输入‘是’,‘否’或指纹”中复制并放置指纹,而不是直接按回车键。


在我的例子中,bitbucket的web ssh密钥设置UI令人困惑。

存储库设置—>接入键—>添加键:错误

个人设置—> SSH密钥—>添加密钥:Ok

公钥注册界面互斥。您只能在一个地方注册公钥。把它们统一在一个屏幕上似乎很好。


我遇到了同样的错误,但如果您再次传递命令,您将注意到提示:您确定要继续连接(是/否)?,然后输入“yes”,然后按回车键就可以解决了。


在极少数情况下,您将得到“致命:无法从远程存储库读取”错误,如在

[user@example.com repo]$ git fetch --all --prune
Fetching origin
exec request failed on channel 0
fatal: Could not read from remote repository.

当Git服务器文件系统已满时。要验证这一点,请运行:

ssh -v ssh://git@yourhost/path/repo.git

如果服务器像这样回复:

...
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/...
SHA256:...
debug1: Server accepts key: /home/...
SHA256:...
Authenticated to linux-git.....com ([xxx.xxx.xx.xx]:xx) using "publickey".
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem full
...
debug1: Remote: PTY allocation disabled.
PTY allocation request failed on channel 0
shell request failed on channel 0

服务器的磁盘空间会被占满。

我知道这个答案不会得到很多人的支持;为了完整起见,添加它。

附注:也可以使用类似

GIT_SSH_COMMAND="ssh -v" git pull

诊断问题。


对我来说非常简单的解决方案,见下面:-

问题

$ 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.

这也会超时

$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

这可能有用

$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

覆盖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

然后再试一次

$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

现在试试克隆(应该有用)

$ 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.

参考:here =>使用端口443的HTTPS


对我来说,这是因为网络。您的网络可能很慢。所以更换网络或排除故障。


在Windows 11上使用这些命令解决了我的问题

1. 我打开Git Bash命令并启动ssh-agent。

eval "$(ssh-agent -s)" // this command only work in git bash.

2. 由ssh-key添加

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"  //it must be 4096
ssh-add id_rsa

3.检查是否正确添加。

ssh-add -l

4. 在GitHub上上传其公钥为(授权密钥)

cat id_rsa.pub | clip

5. 取消设置任何代理和GIT_SSH变量

unset GIT_SSH
git config --global --unset http.proxy
git config --global --unset https.proxy

6. 必须检查github.com应该解决。

ping github.com

7. 现在检查Github的连接性。

ssh -T git@github.com

输出

主机“github.com(20.207.73.82)”的真实性不可能是 建立。ED25519密钥指纹为 SHA256: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx该密钥是未知的 您确定要继续连接吗 (是的/不/(指纹))?警告:永久添加'github.com' (ED25519)到已知主机列表。嗨MHamzaRajput !你已经 成功验证,但GitHub不提供shell访问。


有类似的问题。 我已经通过这条指令(ssh-keygen)生成ssh密钥到我的帐户,或者如果你已经有一个添加它,不生成新的一个。 然后我通过命令shell更改了我的全局凭据,如果你已经克隆了repo,它们也可以在项目根目录中本地更改项目(删除全局标志),但这不是我的情况。 git配置——global user.name“你的姓” Git配置——全局用户。电子邮件“youremail.com”


我解决了这个问题,改变我的url从

https://gitlab.com/{gitlab_user}/project_repo.git

to

https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git

使用命令

git remote set-url https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git