Windows git could not read from remote repository git

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

mudri's user avatar

mudri

7583 silver badges16 bronze badges

asked Nov 22, 2012 at 9:18

user1592380's user avatar

user1592380user1592380

34.5k94 gold badges285 silver badges518 bronze badges

12

Your ssh key most likely had been removed from ssh agent

ssh-add ~/.ssh/id_rsa

where id_rsa is a ssh key associated with git repo

Update

You may get Could not open a connection to your authentication agent. error to resolve that you need to start the agent first by:

eval `ssh-agent -s`

Abdul Baig's user avatar

Abdul Baig

3,6833 gold badges21 silver badges48 bronze badges

answered Oct 12, 2016 at 22:49

Johnny Cage's user avatar

13

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:)

answered Dec 4, 2015 at 5:38

Manish Nakar's user avatar

Manish NakarManish Nakar

4,3061 gold badge18 silver badges13 bronze badges

11

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 abc@***.com:path/to/repo

answered Nov 22, 2012 at 9:24

rob mayoff's user avatar

rob mayoffrob mayoff

377k67 gold badges797 silver badges849 bronze badges

9

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.

answered Dec 21, 2013 at 0:51

Tombart's user avatar

TombartTombart

30.7k16 gold badges123 silver badges137 bronze badges

9

I had a wrong ssh private key for Bitbucket along with the right one in ssh agent.

Deleted all keys first

ssh-add -D

Then added just the right key.

ssh-add ~/.ssh/id_rsa

answered Mar 20, 2020 at 21:55

Foreever's user avatar

ForeeverForeever

7,1499 gold badges53 silver badges56 bronze badges

4

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

eval $(ssh-agent -s)

Source: Github documentation

Roberto Ferraz's user avatar

answered Oct 19, 2015 at 20:05

user3362907's user avatar

user3362907user3362907

3093 silver badges3 bronze badges

3

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.

answered Sep 27, 2015 at 11:45

Bastin Robin's user avatar

0

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

CB.'s user avatar

CB.

5321 gold badge4 silver badges11 bronze badges

answered Jul 30, 2014 at 17:25

Scott Lindner's user avatar

6

I had the same problem.

This error means that you have not specified your remote URL location upon which your code will push.

You can set remote URL by 2 (mainly) ways:

  1. Specify remote URL via executing command on Git Bash.

    • Navigate to your project directory

    • Open Git Bash

    • Execute command:

      • git remote set-url origin <https://abc.xyz/USERNAME/REPOSITORY.git>
  2. Mention remote URL direct in config file

    • Navigate to your project directory

    • Move to .git folder

    • Open config file in text editor

    • Copy and paste below lines

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

For more detailed info visit this link.

answered Apr 18, 2017 at 15:51

Pratik Patel's user avatar

Pratik PatelPratik Patel

2,2393 gold badges23 silver badges30 bronze badges

1

Another workaround:

Sometimes this happens to me because of network problems. I don’t understand the root problem fully, but switching to a different sub-network or using VPN solves it

answered Jun 22, 2015 at 15:07

kip2's user avatar

kip2kip2

6,4934 gold badges55 silver badges72 bronze badges

2

I had the same error.
The solution was following:
I’ve corrected my url in .git/config.
Just copied that from HTTPS clone URL. That would be something like that:

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

It worked.

answered Jan 23, 2015 at 21:05

tan75's user avatar

tan75tan75

1151 silver badge2 bronze badges

3

Pretty straightforward solution that worked for me, see below:-

Problem
$ git clone [email protected]: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.
This should also timeout
$ ssh -T [email protected]
ssh: connect to host github.com port 22: Connection timed out
This might work
$ ssh -T -p 443 [email protected]
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
Override SSH settings
$ 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
Then try again
$ ssh -T [email protected]
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.
Try cloning now (should work)
$ git clone [email protected]: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.

Reference: here => Use HTTPS with Port 443

answered Mar 1, 2022 at 14:35

Shuvo Amin's user avatar

Shuvo AminShuvo Amin

6318 silver badges14 bronze badges

2

After doing some research I’ve finally got solution for this, you have declared a environment variable to plink.exe path. So if you remove that path, reopen the git bash and try cloning through SSH it will work.

Refer to this link

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

Fabio Antunes's user avatar

answered Oct 1, 2013 at 10:38

Mohammed Nasiruddin's user avatar

If after»git push origin master» command u see the error «could not read from remote repository» then try this out

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 

Vega's user avatar

Vega

28k27 gold badges96 silver badges103 bronze badges

answered Feb 10, 2018 at 15:44

sushmitha's user avatar

sushmithasushmitha

791 silver badge2 bronze badges

In your .git/config file

[remote "YOUR_APP_NAME"]
    url = [email protected]:YOUR_APP_NAME.git
    fetch = +refs/heads/*:refs/remotes/YOUR_APP_NAME/*

And simply

git push YOUR_APP_NAME master:master 

answered Jul 27, 2013 at 20:20

user1982195's user avatar

I had a perfectly fine working git and suddenly I got that error when I tried to push to the master. As I found out, it was because the repository host had problems.

If you using GitHub or Bitbucket you can easily check the status at

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

enter image description here

answered Mar 2, 2018 at 17:04

Adam's user avatar

AdamAdam

26.2k23 gold badges158 silver badges248 bronze badges

1

If you use Gitlab than you might need to log in and accept Gitlab new terms, before you try to pull or push.

answered May 23, 2018 at 18:52

Marcelo Agimóvel's user avatar

Marcelo AgimóvelMarcelo Agimóvel

1,6782 gold badges20 silver badges26 bronze badges

2

You need to use HTTPS for Git:

Type this into the Terminal:

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

Then commit:

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

answered May 7, 2020 at 18:26

SwiftiSwift's user avatar

SwiftiSwiftSwiftiSwift

7,64810 gold badges57 silver badges98 bronze badges

1

I have tried everything including generating new key, adding to the GitHub account, editing .ssh/config and .git/config. But still it was giving me the same error.
Then I tried following command and it does work successfully.

ssh-agent bash -c 'ssh-add ~/.ssh/id_rsa; git clone [email protected]:username/repo.git'

answered Mar 1, 2019 at 0:16

Chetan Pangam's user avatar

2

updated OCT 2020

In most of the case when you have more than one user access the same git server from a same client system, that time git server confused to with access key with the user both users allowed but when you fire command that time its used default user.

ssh -T [email protected]

see which user are activatly you try to push with that user

the simple solution removes the unused user public key from the git server.

then try to git fetch or pull, push it will work for me

answered Oct 13, 2020 at 11:14

Mr Coder's user avatar

Mr CoderMr Coder

5173 silver badges13 bronze badges

In my case I was using an ssh key with a password to authenticate with github. I hadn’t set up pageant properly in Windows (only in cygwin). The missing steps were to point the git_ssh environment variable to plink.exe. Also, you need to get github.com into the plink known_hosts.

   plink github.com
   y
   <then ctrl-c>

Hope this helps!

I sure wish intellij would have given me a more useful error, or better yet asked me to type in the ssh key password.

answered Sep 5, 2016 at 1:22

Jeff Hoye's user avatar

Jeff HoyeJeff Hoye

5805 silver badges11 bronze badges

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

  1. Use ssh instead of https.
  2. To use ssh key in git (add ssh key).
  3. If you are root, use the ssh key.

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

$ git init
$ git add file
$ git commit -m "add first file"
$ git remote add origin [email protected]:user/example.git 
$ git push -u origin master

Guillaume Jacquenot's user avatar

answered Sep 18, 2017 at 0:31

Ernesto Sequeira's user avatar

I solved this issue by restarting the terminal (open a new window/tab).

So if you don’t really want/need to understand the underlying problem, test method is worth a try before digging deeper :)

answered Jan 30, 2019 at 10:46

mraxus's user avatar

mraxusmraxus

1,3771 gold badge15 silver badges23 bronze badges

2

I meet the problem just now and fix it by: git config user.email "youremail".


update:
The root cause maybe my poor network and poor proxy.
I still don’t know why it happened, but every time has this error, this command works!!!

answered Sep 21, 2019 at 7:35

FakeAlcohol's user avatar

FakeAlcoholFakeAlcohol

8607 silver badges29 bronze badges

In my case, The bitbucket’s web ssh key setup UI is confusing.

Repository Settings -> Access keys -> Add key : Error

Personal settings -> SSH keys -> Add key : Ok

The public key registration screen is mutually exclusive. You must register the public key only in one place. It seems good to unify them on one screen.

answered Oct 17, 2021 at 2:16

sailfish009's user avatar

sailfish009sailfish009

2,5711 gold badge24 silver badges31 bronze badges

1

My issue was resolved by using these commands on Windows 11

1. I opened up the Git Bash command and started ssh-agent.

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

2. Added by ssh-key

ssh-keygen -t rsa -b 4096 -C "[email protected]"  //it must be 4096
ssh-add id_rsa

3. Check properly added or not.

ssh-add -l

4. Uploaded its public key on GitHub as (Authorization key)

cat id_rsa.pub | clip

5. Unset any proxy and GIT_SSH variable

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

6. Must check github.com should be resolved.

ping github.com

7. Now check Connectivity with Github.

ssh -T [email protected]

Output

The authenticity of host ‘github.com (20.207.73.82)’ can’t be
established. ED25519 key fingerprint is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx This key is not known by
any other names Are you sure you want to continue connecting
(yes/no/[fingerprint])? yes Warning: Permanently added ‘github.com’
(ED25519) to the list of known hosts. Hi MHamzaRajput! You’ve
successfully authenticated, but GitHub does not provide shell access.

answered Sep 2, 2022 at 7:15

M. Hamza Rajput's user avatar

M. Hamza RajputM. Hamza Rajput

7,9072 gold badges42 silver badges36 bronze badges

I resolved this issue by change my url from

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

to

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

using command

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

answered Dec 12, 2022 at 9:30

Al Fahad's user avatar

Al FahadAl Fahad

2,3785 gold badges28 silver badges37 bronze badges

I was facing the same issue. so here’s the way i resolved the same

Step 1:

create a new ssh key:-

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

Step 2:

copy the ssh key on clipboard :-

pbcopy < ~/.ssh/id_ed25519.pub 

Step 3:

now paste copied ssh key to the corresponding git repository

Step 4:
Start the ssh-agent in the background.

$ eval "$(ssh-agent -s)"
> Agent pid 59566

Step 5:
now try accesing the repo

git clone [email protected]:username/repo-name.git

Step 6:

if still you see the issue then check the ssh config file

vim ~/.ssh/config

the content should look like

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Step 7:

Add your SSH private key to the ssh-agent and store your passphrase in
the keychain

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Step 8:

Now try again it should work

git clone [email protected]:username/repo-name.git

answered Aug 15 at 11:06

officialrahulmandal's user avatar

For my case, I am using Corporate network (without internet connection) in office. In order to pull code from github, I set https proxy in gitbash and then use https instead of ssh to pull code,it works fine. However when comes to push code, the https proxy won’t work. So either switch to Internet network (with internet connection) or set ssh proxy can solve the problem.

answered Jul 8, 2015 at 11:00

wenwen's user avatar

wenwenwenwen

1841 silver badge5 bronze badges

Actually I tried a lot of things to make it work on Win7, since changing the SSH exectun fron native to build-it and backwards and the same error.
By chance, i change it to HTTPS in the «.git/config» file as:

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

and it finally worked. So maybe it could work for you as well.

answered Mar 9, 2016 at 22:13

wizardInCloud's user avatar

При первой загрузке/выгрузке изменений в/из Github часто возникает ошибка git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Данная статья раз и навсегда положит этим ошибкам конец!
Ошибка git@github.com: Permission denied (publickey)

Всё то, о чём пойдет речь ниже, можно посмотреть в этом видео

Открываем терминал в том месте где у вас лежит код, который вы хотите интегрировать в Github или Gitlab. Проверяем есть ли уже существующий SSH ключ, для этого вводим команду ниже:
ls -al ~/.ssh
Пример НЕсуществующего ключа SSH:
Пример несуществующего SSH

Пример существующего ключа SSH:
Пример существующего SSH
Если ключ существует переходите сразу к шагу 4 или создайте отдельный новый ключ специально для Github.

ШАГ 2. Генерация нового SSH ключа

  • Введите в терминале команду ниже:
    ssh-keygen -t ed25519 -C «your_email@example.com»
    Пояснения команды:

    ssh-keygen команда для генерации SSH ключа
    -t ed25519 алгоритм шифрования, по умолчанию алгоритм rsa, Github рекомендует использовать алгоритм ed25519
    -C значит «комментарий», все что после этой команды в кавычках будет комментарием
    «your_email@example.com» комментарий, замените на свой email в Github — это нужно чтобы различать SSH ключи между собой, их может быть несколько
  • Теперь нужно указать путь и название файла, можно оставить по умолчанию и нажать Enter, но давайте поменяем имя файла, чтобы понимать что он сгенерирован именно для Github!
    Скопируйте и вставьте путь по умолчанию, поменяйте имя файла и нажмите Enter.
    Ввод названия для SSH ключа
  • Далее нужно будет задать пароль (кодовую фразу) для нашего ключа, пропускаем этот шаг, просто два раза нажимаем Enter, иначе придется постоянно вводить этот пароль.
    Ввод пароля для SSH ключа
  • Если вы все сделали правильно будет примерно также, как на скриншоте ниже:
    Успешно сгенерированный SSH ключ

ШАГ 3. Добавление SSH ключа в SSH-agent

Не пропускайте этот шаг! Без него ничего работать не будет.

Что же такое SSH-agent на сайте habr.com вот такое описание: «ssh-agent — это менеджер ключей для SSH. Он хранит ваши ключи и сертификаты в памяти, незашифрованные и готовые к использованию ssh . Это избавляет вас от необходимости вводить пароль каждый раз, когда вы подключаетесь к серверу.»

  • Сначала запустим SSH-agent командой ниже:
    eval «$(ssh-agent -s)»
    надпись Agent pid 61 (у вас будет любое другое число) говорит о том, что агент успешно запущен!
    SSH-agent запущен
  • Добавьте SSH ключ в SSH агент командой ниже, предварительно поменяв название SSH ключа на ваше:
    ssh-add ~/.ssh/id_ed25519_github
    надпись примерная как на скрине ниже, говорит о том, что ключ успешно добавлен
    SSH ключ добавлен в SSH-agent
  • Добавим конфигурационный файл, чтобы SSH ключ автоматически добавлялся в SSH-agent, введите команду ниже, она создаст файл config, если он отсутствует:
    touch ~/.ssh/config
  • Теперь в созданный файл config добавим следующий текст, заменив id_ed25519_github на название своего ключа, если нужно:

    Host *
      AddKeysToAgent yes
      IdentityFile ~/.ssh/id_ed25519_github

    • Для пользователей MacOS вводим команду ниже, откроется обычный редактор текста, вставляем в него текст и сохраняем изменения
      open ~/.ssh/config
    • Для пользователей Windows вводим команду ниже и нажимаем Enter
      cat > ~/.ssh/config <<EOF
      далее вставить текст, нажать Enter, ввести команду ниже и нажать Enter
      EOF

      Настройка config для автоматического добавления SSH ключа в SSH-agent
  • Проверьте что текст был добавлен в файл config командой
    cat ~/.ssh/config
    должно быть как на скриншоте:
    Успешно добавленный текст в файл config

ШАГ 4. Добавление SSH в Github

Готово! Проверьте что ключ работает

Возвращаемся в наш терминал и вводим команду git pull, файлы должны загрузиться или как в моем случае должна появиться надпись, что все уже обновлено.
Успешное соединение по SSH ключу с Github

Спасибо за внимание!

Ad

At Career Karma, our mission is to empower users to make confident decisions by providing a trustworthy and free directory of bootcamps and career resources. We believe in transparency and want to ensure that our users are aware of how we generate revenue to support our platform.

Career Karma recieves compensation from our bootcamp partners who are thoroughly vetted before being featured on our website. This commission is reinvested into growing the community to provide coaching at zero cost to their members.

It is important to note that our partnership agreements have no influence on our reviews, recommendations, or the rankings of the programs and services we feature. We remain committed to delivering objective and unbiased information to our users.

In our bootcamp directory, reviews are purely user-generated, based on the experiences and feedback shared by individuals who have attended the bootcamps. We believe that user-generated reviews offer valuable insights and diverse perspectives, helping our users make informed decisions about their educational and career journeys.

Find the right bootcamp for you

ck-logo

X

By continuing you agree to our
Terms of Service and Privacy Policy, and you consent to
receive offers and opportunities from Career Karma by telephone, text message, and email.

Время на прочтение
2 мин

Количество просмотров 107K

Много статей (в том числе и на Хабре) посвящено подключению к Git по SSH-ключам. Почти во всех из них используется один из двух способов: либо с помощью puttygen.exe, либо командами ssh-keygen или ssh-add.

Вчера на одном из компьютеров у меня не получилось сделать это для msysgit ни одним из описанных в интернете способов, и я потратил несколько часов на попытки настроить SSH-доступ, так ни чего и не добившись.

Как я решил эту проблему — под катом.

BitBucket всё время ругался на то, что ему требуется подключение с помощью ключа:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Мои попытки сгенерировать ключи, указать пути в переменных среды, привязать ключи к гиту были бесполезны. Либо гит ругался крякозябрами (в случае ssh-agent cmd.exe), либо просто игнорировал всё предложенное.

Решение оказалось куда удобнее и проще. Достаточно запустить в локальном репозитории GIT GUI Here, и в меню перейти в
Help -> Show SSH Key:

Скрины

image

image

Если вы столкнулись с такой проблемой, то скорее всего у вас там ни чего не будет:

Окно генерации SSH Key

image

Ну а дальше читать будут, скорее всего, только самые педантичные… Жмём Generate key, видим окно запроса пароля (два раза) для приватного ключа:

Запрос пароля

image

И видим сгенерировавшийся публичный ключ:

Публичный ключ

image

Копируем его, и добавляем вэб-морду ГИТа (в моём случае это BitBucket; ключи там можно добавить в двух местах — в настройках аккаунта и в настройках проекта, нам первый вариант, ибо второй — для деплоя проекта) [Аккаунт]Управление аккаунтомSSH-ключиДобавить ключ:

Добавление ключа в BitBucket

image

Ну, а дальше — просто делаем что нужно — или пуш, или клон (предполагается, что git remote add вы уже сделали сами). Git спросит, можно ли добавить хост к доверенным, и запросит passphrase (пароль приватного ключа). Всё, можно работать.

Удачных разработок!

PS: Большое спасибо за наводку на решение моему коллеге Ивану!

Fatal: could not read from remote repository. is a Git error message when it fails to connect to your “remote repository” due to a configuration error on your local machine. This article will explain what’s wrong with your compiler and how you can connect to your remote repository.fatal could not read from remote repository

While you go through this article, you’ll learn more about Git and how it works behind the scenes. Now, you’ll need your terminal or command prompt to follow along, so launch either and let’s restore your connection.

Contents

  • Why Git Cannot Read From Your Remote Repository?
    • – Your SSH Key Was Removed From the SSH Agent
    • – Your Remote URL Is SSH in the Configuration File
    • – Another Program Is Using the git_SSH Environment Variable
    • – Your SSH Agent Is Not Running
    • – Network Access Problems on Your Computer
    • – Mismatch of the Local and Remote SSH Key
    • – You Did Not Specify the Remote URL Location
  • How Git Can Read From Your Remote Repository
    • – Add Your SSH Key to Your SSH Agent
    • – Update the Remote URL in the Configuration File
    • – Remove git_SSH Environment Variable
    • – Start Your SSH Agent
    • – Access the Remote Repository Using a Vpn
    • – Update the Remote SSH Key
    • – Set a Remote URL for Git Push Operations
  • Conclusion

Why Git Cannot Read From Your Remote Repository?

Git cannot read from your remote repository because your SSH key was removed from the SSH agent, or the remote URL is SSH in the Git configuration file. Other causes include a mismatch of your local and remote SSH keys, network access problems, or your SSH agent is not running.

The following can also prevent Git from reading from your remote repository:

  • Mismatch of the local and remote SSH key
  • You did not specify the remote URL location

– Your SSH Key Was Removed From the SSH Agent

If you’re connecting to your “Git repository” and your “SSH key” was removed from the SSH agent, Git cannot read from your remote repository. As a result, you’ll get an error because this key allows you to authenticate to the repository without typing your password every time.

So without it, the server hosting the remote repository cannot verify your identity during the connection, and like every system, it will stop you. Factors that can remove your SSH key from the agent include the following:

  • Explicit removal using the “ssh-add -D” command.
  • Manual deletion of the key file.
  • Another program deleted the key without your knowledge.

– Your Remote URL Is SSH in the Configuration File

When the remote URL is SSH in the configuration file (“.git/config”), Git cannot connect to your remote repository if the repository owner did not configure SSH access. So, when you try any “git” operations like “git push”, the communication with the remote repository will break down because there is no medium to continue.Fatal Could Not Read From Remote Repository Causes

For example, the value of the “url” in the following indicates that you’ll like to connect to a GitHub repository using SSH. But you’ll get an error message that includes “access rights”, “correct access” if you did not configure SSH on your repository:

url = git@github.com:your_github_username/your_github_repository.git

– Another Program Is Using the git_SSH Environment Variable

When another computer program on your computer is using the GIT_SSH environment variable, Git will show you an error if you want to read from a remote repository. This type of situation occurs when Cygwin is your preferred terminal environment, and it works fine with SSH.

However, you installed Git on your Windows computer, and this Git installer changed the GIT_SSH variable to “Plink.exe”. The latter is the “PuTTY link” command line tool that will not work with SSH unless you configure it for SSH.

Now, this leads to a conflict on your computer because “Plink.exe” is now using the GIT_SSH variable that’s meant for your configured SSH client in Cygwin. As a result, your SSH client can’t use this environment variable for SSH connections, and you’ll get an error if you initiate an operation that will use SSH.

– Your SSH Agent Is Not Running

The SSH agent is “ssh-agent,” and if it’s not running, you cannot initiate any SSH connection to your remote repository. Here is why: this agent will store your SSH private key that’ll allow you to connect to your remote repository that’s configured for SSH connections. Now, if the agent is not running, you’ve lost the authentication link between your computer and the remote repository. So, when you try a “git push” or “git pull” operation, Git will show an error that it can’t read from your remote repository.

– Network Access Problems on Your Computer

Network access problems on your computer can cause a breakdown of communications between your computer and your remote repository. Your work environment can have network policies in place that can disrupt your Git operations in the name of security.Fatal Could Not Read From Remote Repository Reasons

This can include the use of proxy servers that can decrypt your web traffic while it flows from your computer to the remote repository. The time frame for this operation by the proxy server can prevent Git from reading from your remote repository.

– Mismatch of the Local and Remote SSH Key

The SSH keys on your local machine and your remote repository should be the same for any successful SSH connection. If there is a mismatch (or the key does not exist at all), your Git client will not connect if you’ve configured it for SSH connections.

That’s because the standard way to connect via SSH is to create the key on your computer and upload the same key to your remote repository. Now, if the keys are different, the server that’s hosting your remote Git repository will show a “fatal cannot read error” for your incoming Git operations.

– You Did Not Specify the Remote URL Location

A remote URL location is where you’ll push and pull code from and if you don’t set it, the Git client will have no idea where you want to send your code. As a result, if you try to push your code from your local machine, you’ll get the “fatal read” error. For GitHub, it supports SSH URL and HTTPS URL for remote URL locations, but you’ll get an “correct access rights” error if you don’t set either on your local machine.

How Git Can Read From Your Remote Repository

Git can read from your remote repository if you add your SSH key to your SSH agent, update the remote URL in the configuration file, or remove the GIT_SSH environment variable. Starting your SSH agent or accessing the remote repository using a VPN also works.



Finally, you can update the remote SSH keys or set a remote URL for “git push” operations.

– Add Your SSH Key to Your SSH Agent

The addition of your SSH key to your SSH agent will allow your Git client to connect to your remote repository, and it also prevents the “fatal read error” when you do a “git push”. To add your SSH key to the SSH agent, do the following:

  1. Open your terminal on Linux
  2. Start the SSH agent using the following command: eval ssh-agent -s
  3. Use “exec ssh-agent XXXX” on CentOS where XXXX is the name of your shell environment. For example: “exec ssh-agent fish”
  4. Hit enter on your keyboard.
  5. Type the following to add your SSH key: ssh-add ~/.ssh/id_rsa
  6. Press enter on your keyboard to add the key.
  7. Try your Git operations, and it should work.

If you’re on a Windows computer, do the following instead:

  1. Download Git Bash from their official website.
  2. Type and run the following: eval $(ssh-agent)
  3. Use the following if the previous command does not work: eval “$(ssh-agent -s)”

– Update the Remote URL in the Configuration File

If you don’t have SSH configured on the remote repository, you should update the URL in the configuration file to HTTPS. You can change your remote URL to HTTPS using the following steps:Fatal Could Not Read From Remote Repository Fixes

  1. Open your terminal.
  2. Navigate to your project folder
  3. List the remote URLs using the following: git remote -v
  4. Note the name of the remote URLs from the previous command.
  5. Change the remote URL from Secure Socket Shell (SSH) to HTTPS using the following: git remote set-url origin https://github.com/your_GitHub_username/the_name_of_the_Git_repository.git
  6. Confirm the changes using the following: git remote -v
  7. Try your Git operations, and it should work.

Meanwhile, if you don’t want to use the command line, you can do the following to get the same results:

  1. Open the Git configuration file (“.git/config”). On Windows, it’s a hidden file, and you’ll have to show hidden files via the control panel.
  2. Change the value of the “url” from something like “git@github.com:your_GitHub_username/the_name_of_the_Git_repository.git” to “https://github.com/your_GitHub_username/the_name_of_the_Git_repository.git”

– Remove git_SSH Environment Variable

The removal of the GIT_SSH environment variable will prevent the “fatal” read error if your environment is Cygwin and another program is interfering. To remove the GIT_SSH environment variable, do the following:

  1. Open your terminal or command prompt.
  2. Type and run the following command: unset GIT_SSH
  3. Restart your Git client and restart your computer.
  4. Try a Git operation like “git push” in Cygwin, and it should work.

– Start Your SSH Agent

Your SSH agent is the most important thing when working with the remote repository that’s configured for SSH access. To start your SSH agent, do the following:

  1. Open your terminal.
  2. Type and run the following: eval ssh-agent -s
  3. Try your Git operations and if you get an error, add your SSH key using the “ssh-add” program.

Please note, start the agent using the “eval” as we did above. If you don’t, Git will complain that it cannot connect to your authentication agent. That’s because using “eval” to start the agent will create an environment variable that allows SSH to find the SSH agent. However, if you start the agent as “ssh-agent”, it will start, but SSH will not find it.

– Access the Remote Repository Using a Vpn

If you’re in a corporate environment and you’re getting the “fatal cannot read from remote repository” error, setup a Virtual Private Network (VPN). With a VPN running on your computer, your computer traffic will go through it and connect to your GitHub repository.Fatal Could Not Read From Remote Repository Solutions

– Update the Remote SSH Key

When you update the remote SSH key to match that on your local machine, Git will connect via SSH without an error. To do this update, do the following:

  1. Open your terminal.
  2. Type the following and replace “your_email_id@host.com” with your real email address: ssh-keygen -t rsa -C “your_email_id@host.com”.
  3. Copy the generated RSA “public key” using the following command: cat ~/.ssh/id_rsa.pub
  4. Go to your remote Git repository and paste the key. For GitHub, continue with the next steps.
  5. Log in to your GitHub account.
  6. Click your profile picture in the top-right corner and click on “Settings”.
  7. Click on SSH and GPG keys in the “Access” section.
  8. Click on “Add SSH key” and add a descriptive label for the new key.
  9. Select the purpose of the key.
  10. Paste the key that you copied from your computer and click on “Add SSH key”.

– Set a Remote URL for Git Push Operations

Before you can push to your remote repository, you need to set up a remote URL for the operation. There are methods that you can use, and the following steps detail the first method:

  1. Open your terminal. On Windows, install GitBash.
  2. Switch to your project directory using the terminal.
  3. Type and run the following command: git remote set-url origin https://github.com/your_GitHub_username/your_GitHub_repository.git

The following steps detail the second method, and it’s a modification of the Git’s configuration file:

  1. Open your terminal. On Windows, install GitBash.
  2. Switch to your project directory using the terminal.
  3. Move to the “.git” subdirectory.
  4. Open the “config” file in your code editor.

Paste the following in the “config” file: [remote “origin”]

url = https://github.com/your_GitHub_username/your_GitHub_repository.git

  1. fetch = +refs/heads/:refs/remotes/origin/

Conclusion

This article explained why Git could not read from your remote repository and what you can do to fix it. From our entire discussion, remember the following:

  • If your SSH key is missing from the SSH agent, Git cannot read from your remote repository.
  • When the SSH agent is not running, an attempt to connect to your remote Git repository using SSH will result in the “fatal read” error.
  • You can fix the “fatal could not read from remote repository” error if you add your SSH key to your SSH agent or you switch to HTTPS in the Git configuration file.

Now, you know what it takes to connect to Git without a “fatal” or “permission denied” error. Share our article with your fellow developers and tell them about our site.

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

  • Windows forms панель элементов пропала
  • Windows fundamentals for legacy pcs что это
  • Windows forms application что это
  • Windows fundamentals for legacy pcs скачать
  • Windows full screen windows 7