Skip to content

Instantly share code, notes, and snippets.

@ferki
Created February 19, 2023 21:13
Show Gist options
  • Save ferki/817ebe0069c7bd85823103f5af7e5062 to your computer and use it in GitHub Desktop.
Save ferki/817ebe0069c7bd85823103f5af7e5062 to your computer and use it in GitHub Desktop.
unsupported WIP: Rex passthrough .ssh/config for Net::OpenSSH backend
diff --git a/lib/Rex/Interface/Connection/OpenSSH.pm b/lib/Rex/Interface/Connection/OpenSSH.pm
index 33f01263..6ecbc462 100644
--- a/lib/Rex/Interface/Connection/OpenSSH.pm
+++ b/lib/Rex/Interface/Connection/OpenSSH.pm
@@ -53,28 +53,16 @@ sub connect {
$self->{__auth_info__} = \%option;
Rex::Logger::debug("Using Net::OpenSSH for connection");
- Rex::Logger::debug( "Using user: " . $user );
- Rex::Logger::debug( Rex::Logger::masq( "Using password: %s", $pass ) )
- if defined $pass;
-
- my $proxy_command = Rex::Config->get_proxy_command( server => $server );
-
- $port ||= Rex::Config->get_port( server => $server ) || 22;
- $timeout ||= Rex::Config->get_timeout( server => $server ) || 3;
-
- $server =
- Rex::Config->get_ssh_config_hostname( server => $server ) || $server;
( $server, $port ) = Rex::Helper::IP::get_server_and_port( $server, $port );
- Rex::Logger::debug( "Connecting to $server:$port (" . $user . ")" );
+ Rex::Logger::debug( "Connecting to $server" );
my %ssh_opts = Rex::Config->get_openssh_opt();
Rex::Logger::debug("get_openssh_opt()");
Rex::Logger::debug( Dumper( \%ssh_opts ) );
$ssh_opts{LogLevel} ||= "QUIET";
- $ssh_opts{ConnectTimeout} = $timeout;
my %net_openssh_constructor_options = (
exists $ssh_opts{initialize_options}
@@ -92,7 +80,6 @@ sub connect {
}
my @connection_props = ( "" . $server ); # stringify server object, so that a dumper don't print out passwords.
- push @connection_props, ( user => $user, port => $port );
if (@ssh_opts_line) {
if ( !$net_openssh_constructor_options{external_master} ) {
@@ -102,8 +89,6 @@ sub connect {
push @connection_props, default_ssh_opts => \@ssh_opts_line;
}
- push @connection_props, proxy_command => $proxy_command if $proxy_command;
-
my @auth_types_to_try;
if ( $auth_type && $auth_type eq "pass" ) {
Rex::Logger::debug(
@@ -121,7 +106,7 @@ sub connect {
}
else { # for key auth, and others
Rex::Logger::debug(
- "OpenSSH: key_auth or not defined: $server:$port - $user");
+ "OpenSSH: key_auth or not defined: $server");
push @auth_types_to_try, "key", "pass";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment