Execute testinfra ssh using ssh identity file directly

215 Views Asked by At

Basically, I am trying to run some tests on a remote host using pytest.

Based on https://testinfra.readthedocs.io/en/latest/backends.html is it possible to do so.

I have tried commands like:

$ py.test --ssh-config=/path/to/ssh_config --hosts=node1

And it works fine, where the congif file is like this:

Host node1
  HostName 192.168.1.15
  User root
  Port 22
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  IdentityFile "path_to_ssh_key_file"
  PasswordAuthentication no
  IdentitiesOnly yes
  LogLevel FATAL

And I have tried this one, it works fine. But based on the link, it should also work if we try this option directly using ssh identity file:

py.test --ssh-identity-file=/path/to/key --hosts='ssh://server'

I have tried the command like this:

py.test --ssh-identity-file=/path/to/key --hosts='ssh://[email protected]'

But it is not working, Am I missing something? I really want to run it this way instead of config file...

0

There are 0 best solutions below