SSH known_hosts file not working

jstaffon

New Member
Joined
Dec 2, 2020
Messages
2
Reaction score
0
Credits
35
I've read a lot online about how the "known_hosts" file works and why it's there. I've been using Linux for many years...Ubuntu, Suse, and RedHat flavors. I'm currently working with two Ubuntu machines that, I thought, were configured the same way. One is my home media server (HS)...music, movies, etc...the other is a "NAS" machine of sorts that makes a backup (changes) of HS on a daily basis using "rsync". Needless to say, remote access via CLI is important and I use ssh to accomplish that from my Macbook Air. The weird issue I have is that "ssh" seems to work differently on both the Ubuntu machines even though I was pretty sure I configured them the same. If I ssh from my Macbook Air or the NAS machine to HS, I get the normal ssh interaction where the first time I get the typical challenge to confirm...either Yes or No...that I trust the machine...(eg. Authenticity of host can't be established). From that point on, I don't get that challenge again...no problem there. But, if I ssh from the HS Ubuntu machine to my NAS machine, I continue to get the challenge regardless of the number of times I ssh into the NAS machine. I removed the "known_hosts" file on both machines and checked the permissions but still get the unusual behavior from HS to the NAS machine but not in the other direction...NAS to HS. I don't want to change the global variable that causes the initial challenge that ultimately updates the known_hosts file. I'll also mention that it appears to be updating the known_hosts file. Only thing I can think is the key is being changed for some reason each time I ssh into the NAS machine. Any help would be appreciated. Thanks in advance!

Jeff
 


The only thing I can think of offhand is perhaps the permissions for the .ssh folder, or its contents on the HS machine are incorrect and it’s unable to add your NAS to the known-hosts file because it can’t write to the file.
When you get that message and press y - it should be added to known-hosts....
That’s the only logical explanation I can think of!
 
That's where I looked also. Looks like .ssh permissions were 700 and known_hosts was 644. Just for grins and giggles I deleted the known_hosts file (which I had done before) and allowed it to be recreated. Same permissions, 644, but everything seems to work fine now. I'm not sure why but I seem to be back to normal. It's possible I was focusing on the known_hosts file on the wrong machine.

Just out of curiosity, I noticed that the Macbook Air (flavor of BSD) known_hosts file contains clear text of the machine name (ie. NAS, HS) along with the IP. On the Linux machines, all of the information in the file looks encrypted. Was it always this way or did Ubuntu/Linux make changes there recently?Thanks.
 
Last edited:

Staff online

Members online


Top