Answer the question
In order to leave comments, you need to log in
How to use the paromiko library when connecting to the server to use authorization by key and password?
Help pzhl connect
to the server. by login password.
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=host, username=user, password=secret, port=port)
and how to use the paromiko library when connecting to the server to use key authorization and password. ???
Answer the question
In order to leave comments, you need to log in
The paramiko.SSHClient object has methods load_system_host_keys and load_host_keys. The first loads the keys of the user on whose behalf it is launched, the second loads the specified key. If the key is password-protected, an exception will be thrown (I don't remember which one, but it's easy to check by experiment). Accordingly, in case of an exception, you need to request a password from the console, it is better to do this with the built-in getpass module (it makes it easy to enter a password without an echo).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question