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

后端 未结 5 1329
梦谈多话
梦谈多话 2021-02-10 18:34

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 provide

相关标签:
5条回答
  • 2021-02-10 19:14

    The SSH key on your machine doesn't match the one that you have on record with GitHub. Type

    cat ~/.ssh/id_rsa.pub | pbcopy
    

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

    0 讨论(0)
  • 2021-02-10 19:27

    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 "yourmailid@gmail.com"
    

    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 git@github.com
    

    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 git@github.com:username/ProjectName
    

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

    git push origin master
    

    Hope it will work for you.

    0 讨论(0)
  • 2021-02-10 19:35

    did you add your RSA key with ssh-add?

    ssh-add your-rsa-key

    0 讨论(0)
  • 2021-02-10 19:35

    Sometimes, you may reinitialize the connection to github by just running push command again:

    git push -u origin master
    

    It seems to have worked !

    0 讨论(0)
  • 2021-02-10 19:37

    Some times you must run:

    git pull
    

    Be carefull! Backup your repo folder before run this command.

    0 讨论(0)
提交回复
热议问题