Advertisement
Advertisement


git: fatal: Could not read from remote repository


Question

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
[email protected]***.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 [email protected]***.com. when I connect via ssh to my site I have a different username( lets say 'abc'). so maybe this should be [email protected]***.com. If so I don't know how to change this or if I can push under an alias

2014/02/26
1
368
2/26/2014 3:24:52 PM

Accepted Answer

You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an @, before the remote hostname.

git remote set-url website [email protected]***.com:path/to/repo
2015/03/23
133
3/23/2015 2:39:00 PM


Make sure you have correct url in .git/config

url = [email protected]:username/repo.git

If it's your first push, you'll need to set up correct upstream

$ git push -u origin master

You can check which key is used by:

$ ssh -vvv [email protected]

The reply should contain something like this:

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

Also it's possible to define rules for ssh in ~/.ssh/config, e.g. based on aliases:

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

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

You can set connect to different ports, use different username etc. for each alias.

2013/12/21

I was facing same issue a while ago...

my .git/config had

url = [email protected]:manishnakar/polymer-demo.git

I replaced it with

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

and it works now:)

2015/12/04

Try removing the GIT_SSH environment variable with unset GIT_SSH. This was the cause of my problem.

2015/10/19

Make sure ssh-agent is running by executing the following command on your terminal:

eval $(ssh-agent -s)

Source: Github documentation

2019/02/07

This is usually caused due to the SSH key is not matching with the remote.

Solutions:

  1. Go to terminal and type the following command (Mac, Linux) replace with your email id.

    ssh-keygen -t rsa -C "[email protected]"

  2. Copy the generated key using following command starting from word ssh.

    cat ~/.ssh/id_rsa.pub

  3. Paste it in github, bitbucket or gitlab respective of your remote.
  4. Save it.
2015/09/27