623

I am trying to set git up with http://danielmiessler.com/study/git/#website to manage my site.

I have gotten to the last step in the instructions: git push website +master:refs/heads/master

I am working using the git ming32 command line in win7

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

One problem here may be that the program is looking for Bill@***.com. when I connect via ssh to my site I have a different username( lets say 'abc'). so maybe this should be abc@***.com. If so I don't know how to change this or if I can push under an alias

12

62 Answers 62

2

I had the same issue and after a while I saw I'm under root user (with sudo -s). May this help for someone.

1
  • I confirm that even when you have set up ssh key on your machine and on the BitBucket, it will still display this error if you try to execute 'git pull' with a 'sudo' command. Jul 19, 2019 at 7:39
2

I had this problem using gitbash on windows 10. I tried several things to solve this problem, the major ones being these:

  1. Recreated my ssh keys and updated to bitbucket. Didn't help
  2. Turned on debugging using this and found out that I was getting "shell request failed on channel 0" as asked here
  3. Rebooted my windows PC

None of the above helped. I ended up re-installing Git for windows This took only a few minutes as compared to other things I did and it solved the problem!

1
  • 1
    why I didn't see your answer 2 days ago? I already spend to much time for this fix.... :(
    – Max
    Nov 9, 2021 at 23:47
2

In my case, I was trying to clone with sudo. As per Github's doc, you shouldn't use sudo with git clone: https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey#should-the-sudo-command-be-used-with-git

What I did is give the currrent user permission to edit the directory (Debian 9):

chown myuser:root .

Then cloned without sudo and it worked.

2

Not the OP' problem, but if you're working in a GitHub organization/ team, you might not have write permissions on the repository. Unfortunately, git doesn't show more specific permissions errors. In my case, I was working on a private repository, and had been given "Triage" or "Read" access.

For more information about repository access for each permission level, see GitHub documentation.

The link to change this on GitHub is https://github.com/orgs/ORGANISATION_NAME/teams/TEAM_NAME/repositories, where you can change the permissions given to the team.

Screenshot of github organisation's team's repository's tab

1

For those having this problem on a private remote repo. make sure you have accepted the Xcode agreement on the remote server: it took we weeks to find out this fix

Use this command from the command line: sudo xcodebuild -license

1

In my case it was the postBuffer..

git config --global http.postBuffer 524288000

For reference read: https://gist.github.com/marcusoftnet/1177936

1

I had the same error, which brought me to this answer that didn't help me. I was trying to create a new "bare" repository for the first time using the commands below to track to an NTFS location:

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

My problem turned out to be using the back slashes instead of forward slashes in the NTFS location when trying to add origin to set the (new) tracked upstream branch.

I had to remove the origin using:

git remote rm origin

Then add the origin again using the expected forward slashes

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

Hope this helps someone in the future.

1

I've got this error after changing computers. I'm using SourceTree with Bitbucket.

So I had to add the SSH key generated by SourceTree, on the new computer, in Bitbucket Settings > Security > SSH keys, while connected to my Bitbucket account on the web.

1

I was getting this problem intermittently, where most of the time it would not give the error message. The solution for me was to configure LDAP correctly after my LDAP server's IP address had changed.

The /etc/gitlab/gitlab.rb configuration for LDAP was pointing to a non-existent IP address, and so changing the host to point to the proper hostname for the LDAP server fixed the issue.

To diagnose the issue, use the gitlab-ctl tail command to help you find stacktraces. For me, I found this 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'
...

Make the changes to the host value in /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

After changing the config file above, be sure to reconfigure gitlab

gitlab-ctl reconfigure
1

It could be a Network issue.

Try doing the ssh -vvvT [email protected]. If the server hangs unexpectedly it could be a dodgy network connection.

Put the following in your ~/.ssh/config

IPQoS lowdelay throughput
1

If you have set recievepack or uploadpack in my case i got the error after setting them by mistake

receivepack = powershell git receive-pack

in my case in .git/config

You can remove them as by the answer bellow

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

Or by directly modifying .git/config

1

Sometimes you need to use full URL with ssh:// scheme:

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

or with specified port:

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

For me it solved the problem.

1

run into this because I am in China with Great Firewall...

kex_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

1

In my case the problem and it's solution was written right in front of me. Earlier that day I edited the /etc/ssh/ssh_config file and added some keys. The error said:

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

I deleted the allowusers key and it's value and everything worked as expected.

1

I had the same issue and resolved by updating to the latest git version

1

My solution was quite simple actually. I just had to copy and place the fingerprint from this question "Please type 'yes', 'no' or the fingerprint" instead of just hitting enter.

0

I just wanted to add to this question. I had Git setup to use PLink and Pageant for authentication and I was also getting the error FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey). I had Pageant opened but the error was still showing up. The problem? I didn't have the private key loaded in Pageant (to add a key, follow these instructions). It was that simple.

0

When using putty/pageant, make sure you did not forget to add the correct SSH key to pageant, else this error shows up. DUH

0

Go to MINGW32 terminal put this Command : git branch --set-upstream-to=origin/(branch Name)

0

If you are still getting the same error, please make sure that in the git settings->ssh tab->ssh client to use is set to openSSHenter image description here

0

According to my experience, one of the reasons this problem occured is because you have an unstable internet connection.

0
0

I faced the same issue; simply you can run this on your command window:

git remote add origin https://your/repository/url

0

Adding to the "I had the same problem and...", I am also using git via Ming32 (git bash) shell in Windows.

In my case the repo requires me to type a password, not using SSH key, but it was not prompting for the password, just saying "fatal: Could not read...", although I could SSH in normally, using plink and ssh, and had set both known-host keys.

I tried most of the recommendations here and in other SOs.

I found in the end it worked fine in Powershell, but not in git bash, with no changes or corrections.

0

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.

0

I was getting this error while trying to push code to my personal git from work - defaults point to work git. So I followed these steps:

  1. Went to my personal git account and created repo with default settings
  2. On terminal, git remote add origin [email protected]:/.git
  3. git push --set-upstream origin master, ensuring that origin is upstream and the next commits can be made using git push only.

For some reason, no other way worked for me. Hope this helps someone working with 2 or more git accounts.

0

I encounter this issue by enter many times error password.

so I have to change the MaxAuthTries to a bigger number:

open the sshd_config in server end:

vim  /etc/ssh/sshd_config

change the MaxAuthTries number:

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

In a rare case, you'll get "fatal: Could not read from remote repository" error, like in

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

when Git server filesystem is full. To verify this, please run:

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

If the server replies like this:

...
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 [email protected]
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

then the disk space on the server is exhausted.

I understand that this answer won't get many up-votes; adding it for the sake of completeness.

P.S. It is also possible to use something like

GIT_SSH_COMMAND="ssh -v" git pull

to diagnose the problem.

0

To me, this occurs due to network. Your network might be slow. So change network or troubleshoot it.

0

Had similar problem. I've added ssh key to my account by generating it via this instruction (ssh-keygen) or if you already have one add it and not generating new one. Then I changed my global credentials via command shell, they also can be changed locally for project in project root directory(remove global flag) if you already cloned repo, but it wasn`t my case. git config --global user.name "YourFirstname YourLastname" git config --global user.email "[email protected]"

0

Question has been already answered but here is another way of solving the problem https://medium.com/@deshpasheeto_sisu/error-fatal-could-not-read-from-remote-repository-f987007ee997

This might work for somebody who has no luck with other options.

Not the answer you're looking for? Browse other questions tagged or ask your own question.