New in Git: git push origin master = "ssh_exchange_identifiction: connection closed by remote host. Fatal: remote end hung up unexpectedly"

I tried git for the first time and try to follow github instructions. However, I seem to fail in the last step. The following steps are presented by github:

Global setup: Download and install Git git config --global user.name "Your Name" git config --global user.email Next steps: mkdir SomeFolder cd SomeFolder git init touch README git add README git commit -m 'first commit' git remote add origin git@github.com :username/SomeFolder.git git push origin master 

However, when running the last git command, click on the initial wizard, I get

"ssh_exchange_identification: Connection closed by the remote host. fatal: the remote end hung up unexpectedly"

Why could this be?

+4
source share
5 answers

GitHub is highly secure and respects ssh-rsa. Therefore, we need to configure ssh as the public key for our connection, and let github know about it.

take the terminal and as a user (not root, usually many of us have the habit of typing sudo su as the first command on the terminal, this time avoiding it) Type

 ssh-keygen -t rsa -C " yourmailid@gmail.com " 

Here -t → indicates which encryption -C → try to use the same mail id that you specified for ti github (for convenience of memory)

now you will get two id_rsa and id_rsa.pub files in ~ / .ssh /

now copy all the content to the id_rsa.pub file without changing the contents of the file.

Now go back to your github account. go to account settings →> SSH Public Keys Add a new key and paste the contents that you copied into the "key" field and save (specify the name of your choice).

github now knows how to handle requests from your system.

try

 $ssh git@github.com 

thuis must return hello! UserName is ignored if any error is shown, but make sure it shows Hello! Username

well! now we are going to install a local copy of the repositories on the ouor machine and reflect the changes in the remote system.

create a directory (as user, not root)

 mkdir MyProject cd MyProject git init 

(initialize an empty git repository, see the hidden .git / there folder.) after creating the files in MyProjects, when you want to add it to your repository in github, do

 git add 

now run the status and check the files that you are going to commit next,

 git status git commit -m "Your comment about this commit" 

(this updates the .git / folder in your local repository) now we will tell git about the updated remote repository

 git remote add origin git@github.com :username/ProjectName 

(do you remember where we got this url, its cloning url)

 git push origin master 

Hope this works for you.

+7
source

The SSH key on your computer does not match the one you have on your GitHub record. A type

 cat ~/.ssh/id_rsa.pub | pbcopy 

which will copy your public key to the clipboard. Then go to your GitHub account settings and add it as a new key.

0
source

Have you added the RSA key using ssh-add?

ssh-add your-rsa-key

0
source

Several times you should run:

 git pull 

Be careful! Back up your repo folder before running this command.

0
source

Sometimes you can reinitialize a connection to github by simply running the push command again:

 git push -u origin master 

It seems to have worked!

0
source

All Articles