paramiko.ssh_exception.AuthenticationException: Authentication failed

aramiko is a module written in python language. It follows the SSH2 protocol and supports connection to remote servers through encryption and authentication.

Therefore, if you need to use SSH to connect from one platform to another and perform a series of operations, paramiko is one of the best tools.

Connect to the server via ssh and execute the desired command, similar to XShell

The underlying source code of ansible (remote batch management server) is actually implemented by the paramiko module

Install

pip3 install paramiko==2.8.0

Use paramiko to connect the device on Linux and add the private key file for verification, but the following error message appears:
paramiko.ssh_exception.AuthenticationException: Authentication failed
. The best way to find out is that a higher version of paramiko is used. In the higher version, use the following method to add the private key. key:

paramiko.RSAKey.from_private_key(StringIO(keystr), password='password')
paramiko.RSAKey.from_private_key("keystr", password='password')
This method cannot be parsed in higher versions
and needs to be below 3.0.0 Only then

Guess you like

Origin blog.csdn.net/u010274449/article/details/130718675