Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying out git for the first time and am trying to follow instructions supplied by github. However, I seem to be failing on the last step. The following steps are provided 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 [email protected]:username/SomeFolder.git
  git push origin master

However, when running the final command, git push origin master, I get

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

Why might this be?

like image 644
Chris Avatar asked Feb 28 '23 05:02

Chris


1 Answers

GitHub is highly secured and follow ssh-rsa So we need to setup as ssh public key for our connection, and let github know about it.

take terminal and as user ( not root, usually many of us have a habit of typing sudo su as the first commang at terminal, this time avoid it) type

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

Here, -t -> tells which encryption -C ->try to use the same mail id you have given ti github (for ease of memory)

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

now copy the whole content in file id_rsa.pub without altering the content of the file.

Now go back to you github account. go to account settings >>> SSH Public Keys Add a new Key and paste the content you copied into field "key" and save (give a title of your choice).

now github know to process the requests from your system.

now try

$ssh [email protected]

thuis must return Hi! UserName ignore if any error is shown, but make sure , it shows Hi! UserName

okay! now we are going to set the repositories local copy on ouor machine and reflect changes at the remote system

make a directory ( as user, not root )

mkdir MyProject
cd MyProject

git init

( initialise an empty git repository there, see for a hidden folder .git/ there.) after creating files in MyProjects, when you feel like adding it to your repository at github, do

git add

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

git status

git commit -m "Your comment about this commit"

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

git remote add origin [email protected]:username/ProjectName

( you remember from where we got this URL, its Your Clone URL )

git push origin master

Hope it will work for you.

like image 98
Sumit M Asok Avatar answered Apr 07 '23 03:04

Sumit M Asok