How to fix SmokePing SSH probe on Debian Buster

SmokePing 2.7.3 needs an update to use SSH probe on Debian Buster.

SmokePing stopped working for me on Debian Buster.

SmokePing version.

$ smokeping -V
2.007003
$ apt-cache policy smokeping
smokeping:
  Installed: 2.7.3-2
  Candidate: 2.7.3-2
  Version table:
 *** 2.7.3-2 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status

Operating system version.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

It looks like the openssh-client does not support old key types.

$ sudo smokeping --debug
ERROR: output of '/usr/bin/ssh-keyscan -t dsa,rsa,rsa1 127.0.0.1' does not match (?^i:^# \S+ SSH-)
 at (eval 59) line 1.
$ /usr/bin/ssh-keyscan -t dsa,rsa,rsa1 127.0.0.1
Unknown key type "rsa1"

The solution is to download and install patch from the upstream.

From 62ac9fda04b994bbf4f97d3dd1cf8b92cf279e71 Mon Sep 17 00:00:00 2001
From: "Avinash H. Duduskar" <[email protected]>
Date: Mon, 11 Mar 2019 13:16:13 +0530
Subject: [PATCH] Update SSH.pm to drop SSHv1 rsa1

- Removes rsa1
- Adds ecdsa instead
https://github.com/oetiker/SmokePing/issues/120
---
 lib/Smokeping/probes/SSH.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Smokeping/probes/SSH.pm b/lib/Smokeping/probes/SSH.pm
index ffbb5cc2..f21f53e8 100644
--- a/lib/Smokeping/probes/SSH.pm
+++ b/lib/Smokeping/probes/SSH.pm
@@ -55,7 +55,7 @@ sub new($$$)
     # no need for this if we run as a cgi
     unless ( $ENV{SERVER_SOFTWARE} ) {
         
-        my $call = "$self->{properties}{binary} -t dsa,rsa,rsa1 127.0.0.1";
+        my $call = "$self->{properties}{binary} -t dsa,rsa,ecdsa 127.0.0.1";
         my $return = `$call 2>&1`;
         if ($return =~ m/$ssh_re/s){
             print "### parsing ssh-keyscan output...OK\n";
@@ -132,7 +132,7 @@ sub targetvars {
         return $class->_makevars($class->SUPER::targetvars, {
            keytype => {
                _doc => "Type of key, used in ssh-keyscan -t I<keytype>",
-	       _re => "[dr]sa1*",
+	       _re => "[ecdr]sa*",
                _example => 'dsa',
                _default => 'rsa',
            },

Install patch utility.

$ sudo apt install patch
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  ed diffutils-doc
The following NEW packages will be installed:
  patch
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 126 kB of archives.
After this operation, 249 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 patch amd64 2.7.6-3+deb10u1 [126 kB]
Fetched 126 kB in 0s (414 kB/s)
Selecting previously unselected package patch.
(Reading database ... 35823 files and directories currently installed.)
Preparing to unpack .../patch_2.7.6-3+deb10u1_amd64.deb ...
Unpacking patch (2.7.6-3+deb10u1) ...
Setting up patch (2.7.6-3+deb10u1) ...
Processing triggers for man-db (2.8.5-2) ...

Change working directory to /usr/share/perl5/.

$ cd /usr/share/perl5/

Inspect what would happen.

/usr/share/perl5$ patch --dry-run -p2 < ~/smokeping.patch 
File Smokeping/probes/SSH.pm is read-only; trying to patch anyway
checking file Smokeping/probes/SSH.pm
Hunk #2 succeeded at 130 (offset -2 lines).

Apply patch.

/usr/share/perl5$ sudo patch -p2 < ~/smokeping.patch 
patching file Smokeping/probes/SSH.pm
Hunk #2 succeeded at 130 (offset -2 lines).

SmokePing will start working as expected.

$ sudo smokeping --debug                                                                                                 
### parsing ssh-keyscan output...OK                                                                                                      
### parsing dig output...OK                                                                                                              
### Compiling alert detector pattern 'lossdetect'                                                                                        
### ==0%,==0%,==0%,==0%,==0%,>0%,>0%,>0%
[...]
Smokeping version 2.007003 successfully launched.
Not entering multiprocess mode with '--debug'. Use '--debug-daemon' for that.
DNS: probing 3 targets with step 300 s and offset 97 s.
Curl: probing 2 targets with step 300 s and offset 97 s.
FPing: probing 2 targets with step 300 s and offset 97 s.
SSH: probing 1 targets with step 300 s and offset 97 s.
[...]

Done.