Rex icon indicating copy to clipboard operation
Rex copied to clipboard

Do not set by default SSH port when using Net::OpenSSH

Open nfetisov opened this issue 3 years ago • 1 comments

(R)?ex can't parse complex OpenSSH configuration file, i.e. with host templates, includes, etc. Net::OpenSSH use OpenSSH library and handle complex .ssh/config right like OpenSSH itself.

So if (R)?ex can find port for SSH connection inside (simple plain) .ssh/config - let's use this port value, and if it can't - do not force port to 22/tcp so Net::OpenSSH can try to find it by itself (or failover to the same 22/tcp inside Net::OpenSSH).

This allows complex OpenSSH configs, and resolves related #1209 and #1229 and #1458 issues.

nfetisov avatar Jun 22 '21 14:06 nfetisov

Thanks for your report!

This issue does not fully follow the project's expectations, so I'd like to take this chance to kindly link our Contributing guide, specifically the section about GitHub issues and pull requests.

Please follow the issue template to provide all expected information either by editing the opening post here, or by opening a new issue instead of this one.


It's a correct observation that we'd need to drop the default port value in Rex::Interface::Connection::OpenSSH while we work towards a solution for the overall goal of "don't interfere with ssh config parsing results in Rex when Net::OpenSSH is in use" story. It wouldn't solve the full story in itself, though.

The full picture of the puzzle contains a a few more pieces: add a feature flag to opt-in/out of the new behavior, restructure the code so it becomes testable, drop all default values for connection options (not just port), still ensure that Rex config is respected, etc.

I'd like to open another issue later which describes the overall situation better, and also groups the related issues together (including this one), and then address the root cause instead of just one of the symptoms (e.g. port handling).

ferki avatar Oct 23 '21 20:10 ferki