diff --git a/Changes b/Changes index 70751a90f3..5edefe0ebb 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,7 @@ inventory: parsing may fail if a proxy is enabled * Fix #473: fix arch detection under MacOS * Fix #475: fix video cards support under MacOS +* Fix #504: support non-standard ssh port to report local ssh server pubkey deploy: * Bump Deploy task version to 2.7 diff --git a/lib/FusionInventory/Agent/Task/Inventory/Generic/SSH.pm b/lib/FusionInventory/Agent/Task/Inventory/Generic/SSH.pm index 3238707fa4..8d337d1518 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Generic/SSH.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Generic/SSH.pm @@ -16,10 +16,21 @@ sub doInventory { my $inventory = $params{inventory}; + my $port; + my $command = "ssh-keyscan"; + if (-e '/etc/ssh/sshd_config') { + foreach my $line (getAllLines( file => '/etc/ssh/sshd_config' )) { + next unless $line =~ /^Port\s+(\d+)/; + $port = $1; + } + } + $command .= " -p $port" if $port; + # Use a 1 second timeout instead of default 5 seconds as this is still # large enough for loopback ssh pubkey scan. + $command .= ' -T 1 127.0.0.1'; my $ssh_key = getFirstMatch( - command => 'ssh-keyscan -T 1 127.0.0.1', + command => $command, pattern => qr/^[^#]\S+\s(ssh.*)/, @_, );