Score:0

Host key verification failed SSH Github

cn flag

I've taken a relatively simple approach to try and securely clone my GitHub repo but still struggling.

On My Mac I ran specifying name as MyKey and no password

ssh-keygen -t rsa

I uploaded the contents of the public key to GitHub with read and write access. Then I ran the following commands on my server:

cat > /root/.ssh/github.id_rsa << EOF
-----BEGIN OPENSSH PRIVATE KEY-----
The private key 
-----END OPENSSH PRIVATE KEY-----
EOF

chmod 600 /root/.ssh/github.id_rsa
    
cat > /root/.ssh/config << EOF
    Host github.com
    Hostname github.com
    IdentityFile ~/.ssh/github.id_rsa
EOF
chmod 600 /root/.ssh/config

git clone [email protected]:myname/myproject.git /var/www/test

However the error I get back is:

Cloning into '/var/www/test'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Where might I have gone wrong?

in flag
The host key is the ssh key of the server. Ssh compares the key it had saved on first connect in known_hosts file. If it is different you get this error. Make sure the key you see is one of these https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.