knipknap / exscript

A Python module making Telnet and SSH easy
MIT License
365 stars 136 forks source link

auth_type hard coded in ssh2 module #172

Open maximumG opened 6 years ago

maximumG commented 6 years ago

https://github.com/knipknap/exscript/blob/cc0b63befdc8f4465af5befeed1d26ce26f1944d/Exscript/protocols/ssh2.py#L273

The supported auth_type are hardcoded in the ssh2 module. I propose to have the possibility to set the auth_type inside the SSH2 constructor which will override the hardcoded one.

The use case is to speed up authentication phase when we know which authentication type to use (most of the time password authentication), so that we don't spend extra time testing interactive, auth_agent, auto_key.

lathspell commented 6 years ago

Have you measured a noticable effect? When I run ssh -v $host | ts '%.S' I can only see 0.15s or so between SSH2_MSG_SERVICE_ACCEPT and "Next authentication method: password".

maximumG commented 6 years ago

Basically we are using some devices (Huawei) which are drastically long to send the public key so each re-connection/disconnection (before my last pull request) would lead in 10s before getting the actual prompt after password authentication.

On the other hand, when using Exscript in a multiprocessing environment for up to 7000 hosts, I think that this 0.15s matters.

I will create a patch and send a pull request if someone from the project agree with this.

knipknap commented 6 years ago

The use case makes sense to me... though I assume you mean that auth_method should be configurable, not auth_types. (auth_types is just a map.)