tbot icon indicating copy to clipboard operation
tbot copied to clipboard

Paramiko SSHException: not found in known_hosts

Open drewwestrick opened this issue 3 years ago • 2 comments

I'm having some trouble connecting to a Raspberry Pi as a Lab config. I'm getting the follow error when I try to run the interactive_lab command. I can connect using the command ssh 172.16.100.119 without a password just fine. This connection is also in the known_hosts file.

paramiko.ssh_exception.SSHException: Server '172.16.100.119' not found in known_hosts

ssh_config

Host 172.16.100.119
  HostName 172.16.100.119
  User pi
  IdentityFile /home/drewwestrick/.ssh/rasp_pi

tc.py

import tbot
from tbot.machine import connector, linux

class AwesomeLab(
    connector.ParamikoConnector,
    linux.Bash,
    linux.Lab,
):
    name = "172.16.100.119"
    hostname = "172.16.100.119"
    username = "pi"

    @property
    def workdir(self):
        return linux.Workdir.athome(self, "tbot-workdir")


# tbot will check for `LAB`, don't forget to set it!
LAB = AwesomeLab
```c

drewwestrick avatar Sep 01 '21 16:09 drewwestrick

I think I found one workaround for now. If I add a ignore_hostkey = True after the username property, it allows me to make a connection. It does appear that Paramiko is doing a load_system_host_keys which I believe is reading the ~/.ssh/known_hosts file. What I still don't understand is why it doesn't find my Server in that file even though a regular ssh command from the command line seems to be doing that just fine.

drewwestrick avatar Sep 01 '21 17:09 drewwestrick

Hi, thanks for the report. This looks odd indeed, I never had a problem like this... But it certainly looks like an upstream paramiko issue, I think.

To be quite honest, I would suggest that you switch to using the connector.SSHConnector instead. It uses the ssh command exactly like you would and thus sidesteps all of those odd issues from differences between OpenSSH and Paramiko...

For performance, I very much suggest also enabling the use_multiplexing = True option.

Rahix avatar Sep 03 '21 09:09 Rahix