Score:2

Why does SSH think I still have a 'known_hosts2' file?

in flag

While trying to clean up my SSH config and key files on my iMac (macOS Monterey 12.1), I tried to SSH using the verbose flag (-v). This generated output including the following lines:

...
debug1: load_hostkeys: fopen /Users/clint/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
...

I know that I tried to create a backup of my known_hosts file (and called it "known_hosts2") but I've since deleted it.

Does anyone know how can I find out why SSH still references (and thinks I have) an old file called 'known_hosts2'?

Thanks!

Paul avatar
cn flag
Have you tried `locate known_hosts`?
in flag
I tried it and it only found a Ruby file in Homebrew (known_hosts.rb). I'll read up on using 'locate' but this has made me realize that my original title for this post "How can I find all known_hosts files?" is misleading. What I really want to do is find out why SSH thinks I still have a file named 'known_hosts2'. I will re-title this post. Thank you.
Score:4
in flag

The default configuration for ssh in openssh has UserKnownHostsFile set to ~/.ssh/known_hosts and. ~/.ssh/known_hosts2. The config is similar for GlobalKnownHostsFile except it looks for these files in /etc/ssh as seen in the man page (https://www.man7.org/linux/man-pages/man5/ssh_config.5.html). So openssh ssh checks those 4 files by default which is what you see in ssh -v.

I'm not sure how much the configuration (and implementation) of MacOS SSH differs from openssh default, but at least in this case they seem to behave the same.

in flag
I marked this as the correct answer. I think it was just a coincidence that I backed up the 'known_hosts' file and called the backup 'known_hosts2'. This is also the name of the SSH2 file that SSH is looking for in the SSH -v output that I saw.
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.