Friday, April 22, 2022

[SOLVED] Paramiko equivalent for OpenSSH directives PreferredAuthentications=password and PubkeyAuthentication=no

Issue

Can I get Paramiko code for the following ssh command?

ssh [email protected] -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



Answered By - Martin Prikryl
Answer Checked By - Mary Flores (WPSolving Volunteer)