Search code examples
pythonsshparamikoopenssh

Paramiko equivalent for OpenSSH directives PreferredAuthentications=password and PubkeyAuthentication=no


Can I get Paramiko code for the following ssh command?

ssh Administrator@xx.xx.xx.xx -vv -o PreferredAuthentications=password -o PubkeyAuthentication=no

Need to know how to handle fields PreferredAuthentications and PubkeyAuthentication in Paramiko.


Solution

  • There's no direct equivalent, as Paramiko has different logic than ssh when selecting the authentication methods. And you actually didn't tell us why are you using those directives.

    If your point was to avoid using autodiscovered key files, use allow_agent=False and look_for_keys=False.

    See Force password authentication (ignore keys in .ssh folder) in Paramiko in Python