RSA host key addition

Guys

How do i add RSA key for a host ?

I was able to connect to a host some time back but now its not connectable ,via SSH.

Message i get is :

abhi@myHost:~/.ssh> ssh eatcid@yourHost
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
<KEY_PRINTED_HERE>
Please contact your system administrator.
Add correct host key in </myHome/.ssh/known_hosts> to get rid of this message.
Offending key in </myHome/.ssh/known_hosts>:78
RSA host key for 'yourHost' has changed and you have requested strict checking.
Host key verification failed.

I can see 'known_hosts' file under '.ssh' folder in my home dir.
But i do not know how to add this key in here.

I do not think i can simply add the key in this file directly.

Kindly advice.

Regards
Abhi

It means that you have a saved (cached, if you will) host key in line 78 of known_hosts that conflicts with the current host key sent by the server. Just delete line 78 of your known_hosts file and you should be able to connect. You can also disable strict host key checking altogether in your ssh preferences (~/.ssh/config, man ssh_config).

Okay !!

that works !!....but this i am trying manually....

Lets say on Host A ,i nullified "known_hosts" file

What if Host A now needs to connect to Host 1,Host 2.....Host n..... via SSH ,through a script ?

Will the new keys be added automatically ?

Regards
Abhi

Yes, if you disable strict host key checking.

man ssh_config

should answer any questions you have.

Also, you could add them yourself, check out ssh-keyscan.