Rahix / tbot

Automation/Testing tool for Embedded Linux Development
https://tbot.tools
GNU General Public License v3.0
91 stars 21 forks source link

Paramiko SSHException: not found in known_hosts #60

Open drewwestrick opened 3 years ago

drewwestrick commented 3 years ago

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 commented 3 years ago

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.

Rahix commented 3 years ago

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.