M BUZZ CRAZE NEWS
// news

How to remove offending key in git when you try to push your changes?

By Daniel Rodriguez

I've done tons of search and tested different solutions, but gain no success!

When I want to push my codes, I receive the following error:

Warning: the ECDSA host key for 'git.mywebsite.ir' differs from the key for the IP address '164.138.23.11'
Offending key for IP in /home/alireza/.ssh/known_hosts:10
Matching host key in /home/alireza/.ssh/known_hosts:1
Are you sure you want to continue connecting (yes/no)? yes

What should I do to remove this message every time I push my changes? Any idea?

key list

3 Answers

It says:

Offending key for IP in /home/alireza/.ssh/known_hosts:10

So for some reason you have to delete 10-th line in known_hosts.

Run this command to delete 10-th line in known_hosts:

sed -i '10d' ~/.ssh/known_hosts

Or use ssh-keygen

ssh-keygen -R git.mywebsite.ir

Quote from man

 -R hostname Removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts (see the -H option above).
6

When I got the messages:

Offending key for IP in /home/myusername/.ssh/known_hosts:12

Notice the line number - in my case - 12

So open 'known_hosts' file and delete the 12-th row.

For me this solved the problem.

P.s. Notice if you cannot find the .ssh folder - the .ssh folder is hidden and in order to see it from the file manager - you have to "Show hidden files and folders". In Linux Mint (and possible in your distro too) when in the file manager - there is a shortcut to show/hide hidden folders -> Ctrl+H

Cheers

You have to edit your known_hosts file (located in ~/.ssh/known_hosts) and remove an entry asociated with this address.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy