I am trying to lớn mix git up with http://danielmiessler.com/study/git/#website to lớn manage my site.

I have gotten to lớn the last step in the instructions: git push trang web +master:refs/heads/master

I am working using the git ming32 command line in win7

$ git push trang web +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 lớn my site I have a different username( lets say 'abc'). sánh maybe this should be abc@***.com. If sánh I don't know how to lớn change this or if I can push under an alias

mudri

7703 silver badges18 bronze badges

asked Nov 22, 2012 at 9:18

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 lớn your authentication agent. error to lớn resolve that you need to lớn start the agent first by:

eval `ssh-agent -s`

Abdul Baig

3,7213 gold badges22 silver badges48 bronze badges

answered Oct 12, năm 2016 at 22:49

14

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, năm ngoái at 5:38

13

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

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

answered Nov 22, 2012 at 9:24

10

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 lớn mix up correct upstream

$ git push -u origin master

You can kiểm tra which key is used by:

$ ssh -vvv [email protected]

The reply should contain something lượt thích 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 lớn 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 mix connect to lớn different ports, use different username etc. for each alias.

answered Dec 21, 2013 at 0:51

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 trăng tròn, 2020 at 21:55

6

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

eval $(ssh-agent -s)

Source: Github documentation

answered Oct 19, năm ngoái at 20:05

3

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

Solutions:

  1. Go to lớn terminal and type the following command (Mac, Linux) replace with your gmail 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, năm ngoái at 11:45

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

CB.

5321 gold badge4 silver badges11 bronze badges

answered Jul 30, năm trước at 17:25

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 mix remote URL by 2 (mainly) ways:

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

    • Navigate to lớn your project directory

    • Open Git Bash

    • Execute command:

      • git remote set-url origin
  2. Mention remote URL direct in config file

    • Navigate to lớn your project directory

    • Move to lớn .git folder

    • Open config tệp tin 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 liên kết.

answered Apr 18, 2017 at 15:51

1

Another workaround:

Sometimes this happens to lớn má because of network problems. I don't understand the root problem fully, but switching to lớn a different sub-network or using VPN solves it

answered Jun 22, năm ngoái at 15:07

3

Pretty straightforward solution that worked for má, see below:-

Problem
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to lớn 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 lớn 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 tệp tin and copy/paste the section below
# Add section below to lớn 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

3

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 lượt thích that:

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

It worked.

answered Jan 23, năm ngoái at 21:05

3

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 lớn 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

28.6k28 gold badges120 silver badges145 bronze badges

answered Feb 10, 2018 at 15:44

I was facing the same issue. sánh 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 lớn 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 kiểm tra the ssh config file

vim ~/.ssh/config

the nội dung should look like

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

Step 7:

Add your SSH private key to lớn 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, 2023 at 11:06

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

Refer to lớn this link

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

answered Oct 1, 2013 at 10:38

You need to lớn 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

1

updated OCT 2020

In most of the case when you have more kêu ca one user access the same git server from a same client system, that time git server confused to lớn with access key with the user both users allowed but when you fire command that time its used mặc định user.

ssh -T [email protected]

see which user are activatly you try to lớn push with that user

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

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

answered Oct 13, 2020 at 11:14

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

If you using GitHub or Bitbucket you can easily kiểm tra the status at

https://githubstatus.com/ or https://status.bitbucket.org/

answered Mar 2, 2018 at 17:04

1

In your .git/config tệp tin

[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

If you use Gitlab kêu ca you might need to lớn log in and accept Gitlab new terms, before you try to lớn pull or push.

answered May 23, 2018 at 18:52

2

user@server:/etc/nginx$ cát .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
$ cát /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

answered Sep 18, 2017 at 0:31

I have tried everything including generating new key, adding to lớn the GitHub tài khoản, editing .ssh/config and .git/config. But still it was giving má 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

2

In my case, The bitbucket's trang 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 lớn unify them on one screen.

answered Oct 17, 2021 at 2:16

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 kiểm tra github.com should be resolved.

ping github.com

7. Now kiểm tra 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 lớn continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to lớn 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

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

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

answered Jul 8, năm ngoái at 11:00

1

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

   plink github.com
   y
   

Hope this helps!

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

answered Sep 5, năm 2016 at 1:22

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

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

answered Jan 30, 2019 at 10:46

2

I meet the problem just now and fix it by: git config user.gmail "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

Actually I tried a lot of things to lớn make it work on Win7, since changing the SSH exectun fron native to lớn build-it and backwards and the same error. By chance, i change it to lớn HTTPS in the ".git/config" tệp tin 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, năm 2016 at 22:13