Git error: “Host Key Verification Failed” when connecting to remote repository

I am trying to connect to a remote Git repository that resides on my web server and clone it to my machine.

I am using the following format for my command:

  • How to recover deleted remote branch in Git
  • Git checkout between Ubuntu version
  • How does git know which commit to check a submodule out at?
  • npm outdated output colour-coding meaning
  • How to tell if a Github repository is an R package
  • Merging XML file changes in git
  • git clone ssh://username@domain.com/repository.git
    

    This has worked fine for most of my team members. Usually after running this command Git will prompt for the user’s password, and then run the cloning. However, when running on one of my machines I get the following error:

    Host key verification failed.

    fatal: Could not read from remote
    repository.

    We are not using SSH keys to connect to this repository, so I’m not sure why Git is checking for one on this particular machine.

  • git hooks post-merge
  • How to modify fetch parameter in git config file using command line?
  • Maintaining unrelated directories in one git repository
  • Setting the right path on Heroku for a vendor library
  • What tools do you use to faciliate Continuous Integration (CI)?
  • CruiseControl.NET hangs on git-submodule bad file descriptor with TFS
  • 11 Solutions collect form web for “Git error: “Host Key Verification Failed” when connecting to remote repository”

    You are connecting via the SSH protocol. Using SSH, every host has a key. Clients remember the host key associated with a particular address and refuse to connect if a host key appears to change. This prevents man in the middle attacks.

    The host key for domain.com has changed. If this does not seem fishy to you, you can remove the old key from your local cache using

    $ ssh-keygen -R domain.com
    

    I strongly encourage you to consider having users authenticate with keys as well. That way, ssh-agent can store key material for convenience (rather than everyone having to enter her password for each connection to the server), and passwords do not go over the network.

    As I answered previously in Cloning git repo causes error – Host key verification failed. fatal: The remote end hung up unexpectedly, add the GitHub to the list of authorized hosts:

    ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

    I had the similar issue, but, using SSH keys. From Tupy’s answer, above, I figured out that the issue is with known_hosts file not being present or github.com not being present in the list of known hosts. Here are the steps I followed to resolve it –

    1. mkdir ~/.ssh
    2. vim known_hosts – if you already have known_hosts, skip this.
    3. ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
    4. ssh-keygen -t rsa -C "user.email"
    5. Add the id_rsa.pub key to SSH keys list on your GitHub profile.

    I got the same problem on a newly installed system, but this was a udev problem. There was no /dev/tty node, so I had to do:

    mknod -m 666 /dev/tty c 5 0
    

    Its means your remote host key was changed (May be host password change),

    Your terminal suggested to execute this command as root user

    $ ssh-keygen -f "/root/.ssh/known_hosts" -R [www.website.net]
    

    You have to remove that host name from hosts list on your pc/server. Copy that suggested command and execute as a root user.

    $ sudo su                                                        // Login as a root user
    
    $ ssh-keygen -f "/root/.ssh/known_hosts" -R [www.website.net]    // Terminal suggested command execute here
    Host [www.website.net]:4231 found: line 16 type ECDSA
    /root/.ssh/known_hosts updated.
    Original contents retained as /root/.ssh/known_hosts.old
    
    $ exit                                                           // Exist from root user
    

    Try Again, Hope this works.

    If you are in office intranet (otherwise dangerous) which is always protected by firewalls simply have the following lines in your ~/.ssh/config

    Host *
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

    I had the similar issue, unfortunately I used the GitExtensions HMI and forgot that I wrote a passphrase.
    With HMI…. forget it ! Do not enter passphrase when you generate your key !

    You can use your “git url” in ‘https” URL format in the Jenkinsfile or wherever you want.

    git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'

    Ok i just forked the repo that I wanted to work with then use that…

    Here is what I wanted to do:

    npm install 'mtorromeo/vue-strap#vue2'
    

    I then got that error that brought me here:

    Host key verification failed.
    
    fatal: Could not read from remote repository.
    

    I then just forked that repo and now I could use:

    npm install 'emahuni/vue-strap#vue2' --save-dev
    

    I think the next logical step is to sync upstream:

    git remote add upstream https://github.com/mtorromeo/vue-strap.git
    

    so that changes from upstream are pulled locally when i do:

    git fetch upstream
    

    😉

    For me, I just had to type “yes” at the prompt which asks “Are you sure you want to continue connecting (yes/no)?” rather than just pressing Enter.

    According to the San Francisco State University website:

    This either means that the host has a new key and the fingerprint has changed or that you are the victim of a man-in-the-middle exploit. In order to protect you, the Mac OS X SSH client will not let you complete the connection to this host until the old key is removed from your computer. If you determine that the host’s key has been changed (see connection instructions for current keys), follow these steps to remove the old key:

    • Open Terminal in the Applications > Utility folder.
    • Type open .ssh in the terminal window then press the Return key.
    • This opens the .ssh folder which contains the file known_hosts.
      Drag known_hosts into the trash then close the .ssh folder.
      Close Terminal.
    Git Baby is a git and github fan, let's start git clone.