From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SJoZE8UkN2M3FgEAbAwnHQ (envelope-from ) for ; Fri, 30 Sep 2022 19:17:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4B35EsUkN2NKUwEAauVa8A (envelope-from ) for ; Fri, 30 Sep 2022 19:17:57 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EFFCD22C08 for ; Fri, 30 Sep 2022 19:17:56 +0200 (CEST) Received: from localhost ([::1]:39254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeJe8-0005ZR-5V for larch@yhetil.org; Fri, 30 Sep 2022 13:17:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeJQl-0003pD-0I for guix-patches@gnu.org; Fri, 30 Sep 2022 13:04:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeJQg-0008Sd-D7 for guix-patches@gnu.org; Fri, 30 Sep 2022 13:04:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oeJQf-00051Y-TQ for guix-patches@gnu.org; Fri, 30 Sep 2022 13:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#39136] [PATCH] * gnu: endlessh: new service References: <874kwx91k6.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me> In-Reply-To: <874kwx91k6.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me> Resent-From: Joshua Branson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 30 Sep 2022 17:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39136 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 39136@debbugs.gnu.org Cc: ludo@gnu.org, =?UTF-8?Q?Nicol=C3=B2?= Balzarotti Received: via spool by 39136-submit@debbugs.gnu.org id=B39136.166455741719269 (code B ref 39136); Fri, 30 Sep 2022 17:04:01 +0000 Received: (at 39136) by debbugs.gnu.org; 30 Sep 2022 17:03:37 +0000 Received: from localhost ([127.0.0.1]:42820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeJQG-00050i-EE for submit@debbugs.gnu.org; Fri, 30 Sep 2022 13:03:36 -0400 Received: from mx1.dismail.de ([78.46.223.134]:48344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeJQA-00050R-8B for 39136@debbugs.gnu.org; Fri, 30 Sep 2022 13:03:34 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 81f45e3b; Fri, 30 Sep 2022 19:03:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h=from:to:cc :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=20190914; bh=2bz8z2cvINgNOa7KNCOgw bW4BV4sOi/jRH/vioDDsYc=; b=hx7VO6l7enwCGsX7ckmvaM+Z8/M/IOdIaLMEE Eaacavg0lEOypdJ5cPk7q8C3yseiOj+wfTZIn88VxH72LUA5U5E7I1CUQP9T6U0V 0iW1cMceAYkNZj2r5Xepbvn4SaV2ra/R2hV2aGCO9//6jiMh5JaQAgzt+KfJaOUZ /gfWxmZBR5bWRrhDpq38vu4eC3yH4+jvHwosQxWchTvqetErSkhyU/LfNQzmjfdY 1BuAkKYls8cqCxR0l1Mi6iQ3htzX5BfH2zH4xNUBM7A/ssTA4a3xTwMI80s7Easp DxBGOmPmSOKoUwkCBN3Nj0dWiHdoeMqpJVS0r3BHDTNh0NHzg== Received: from smtp1.dismail.de ( [10.240.26.11]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 4be987a2; Fri, 30 Sep 2022 19:03:23 +0200 (CEST) Received: from smtp1.dismail.de (localhost [127.0.0.1]) by smtp1.dismail.de (OpenSMTPD) with ESMTP id 9d81ceeb; Fri, 30 Sep 2022 19:03:23 +0200 (CEST) Received: by dismail.de (OpenSMTPD) with ESMTPSA id 05cba35b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 30 Sep 2022 19:03:22 +0200 (CEST) Date: Fri, 30 Sep 2022 13:03:01 -0400 Message-Id: <20220930170301.21324-1-jbranso@dismail.de> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Joshua Branson X-ACL-Warn: , Joshua Branson via Guix-patches From: Joshua Branson via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664558277; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DdYbCnvXp8Wfvz9Umi1lD5HNy/RqFM1Ie6n1MyCgJhM=; b=scKsGhnWxh7PrlD9U41pVobp5Y8aJaJwgxIguMqNbb5CBTIqNL2HiGLlsotLwKKum8TW6I HYAQO5t0SDfm6kg3+mBaOuEzP4Z5yc9k73SvsQSkw0h63NTPEN2enp2z77wa5YblyhQ8wz 27yTcycBnRGpdOsvH45HFALPI9f/J+tLc+Hksdtopj1gdjTJEA7fdPaf9glmbpv17FL4T5 D4TGuZFYs/FEy7Uhv0fQFDbDNcwK3kVTaUMu5XP3ihOlyz+fodXHk0bFBOkb05ojYr7Zig 0qziN/gQIO6RjRe8s5caxOynCRoLl+Ghi2r9JpJa+7ASR+QkQ4KCdxTH2rPRFg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664558277; a=rsa-sha256; cv=none; b=m4dh23vd4ZJGqRq42wK1W3zNZpFoprWL7yGgGJiPUNrgsAjvBRWYES5BGZo+iwWCuvgvku HZTy7hv6XO6IlvREyYcLrSrwlmtl41DBaZ8tXqFh4QVVT6QTL+YqrYWTG9RYGMUZPX3uAH fRh2IWgWq8jjSYG8m3DfdyFZdJSVOccZzdpdNn6q4vYeAyZrZXKNoOMIAYz/BQGhle4u4Y eQ6dqVSVf2GizLeQn/dXVjE59m8/Ixn9D0brS7YNRY7HoSKxYJZR952m+aWlE6ujwrI/Yo XwQVrgrsKUHMudDNMUa73n+r4p9iSaEGGhI4JoVkGOw9RNFgpbDGkcRji/CgjA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=hx7VO6l7; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.54 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=dismail.de header.s=20190914 header.b=hx7VO6l7; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: EFFCD22C08 X-Spam-Score: -4.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: /A7nNyWrfnAG From: Nicolò Balzarotti Here is an attempted merger of patch 1 and 2. I hope that it applies cleanly to master, but if it does not, please let me know! Thanks! Joshua * gnu/services/ssh.scm: Add endlessh service endlessh-configuration>): New record type. (endlessh-config->conf, endlessh-shepherd-service, endlessh-service-type): New procedures. * doc/guix.texi: added documnetation for the endlessh service. --- doc/guix.texi | 60 ++++++++++++++++++++++++++++++++++++ gnu/services/ssh.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 99f8ba6c54..9a1e2801dd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -20393,6 +20393,66 @@ may cause undefined behaviour. @end table @end deftp +@cindex Endlessh +@deffn {Scheme Variable} endlessh-service-type +This is the type for the @uref{https://github.com/skeeto/endlessh, +Endlessh} service, which is an ssh tarbit. It delays ssh clients for +days at a time by @emph{very slowly} sending a random and endless SSH +banner. The smart hacker will run endlessh on port 22, and let crackers +get stuck in this tarpit. This lets your real ssh server run more +securely on a non-standard port. + +For example: + +@lisp +(service endlessh-service-type + (endlessh-configuration + (port-number 22))) +@end lisp + +@end deffn + +@deftp {Data Type} endlessh-configuration +Data type representing the configuration for @code{endlessh-service}. +@table @asis +@item @code{package} (default: @var{endlessh}) +@code{endlessh} package to use. + +@item @code{bind-family} (default: @code{'(ipv4 ipv6)}) +This specifies if endlessh should use ipv4 and/or ipv6. + +@item @code{delay} (default: @code{10000}) +The endless banner is sent one line at a time. This is the delay +in milliseconds between individual lines. + +@item @code{length} (default: @code{32}) +The length of each line is randomized. This controls the maximum length +of each line. Shorter lines may keep clients on for longer if they give +up after a certain number of bytes. + +@item @code{max-clients} (default: @code{4096}) +Maximum number of connections to accept at a time. Connections beyond +this are not immediately rejected, but will wait in the queue. + +@item @code{port-number} (default: @code{2222}) +The port on which to listen for new SSH connections. Most users who +want to use endlessh as intended should set this port number to +@code{22}. + +@item @code{log-level} (default: @code{0}) +Set the detail level for the log. +@table @asis +@item 0 = Quiet +@item 1 = Standard, useful log messages +@item 2 = Very noisy debugging information +@end table + +@item @code{syslog} (default: @code{#f}) +Print diagnostics to syslog instead of standard output + +@end table +@end deftp + @cindex WebSSH @deffn {Scheme Variable} webssh-service-type This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH} diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index 72e7183590..2e547b63cd 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm @@ -58,6 +58,10 @@ (define-module (gnu services ssh) autossh-configuration? autossh-service-type + endlessh-configuration + endlessh-configuration? + endlessh-service-type + webssh-configuration webssh-configuration? webssh-service-type @@ -802,6 +806,75 @@ (define autossh-service-type autossh-service-activation))) (default-value (autossh-configuration)))) + +;;; +;;; Endlessh. +;;; + +(define-record-type* + endlessh-configuration make-endlessh-configuration + endlessh-configuration? + ;; list of two symbols, allowed values are ipv4, ipv6 or both + (bind-family endlessh-configuration-bind-family (default '(ipv4 ipv6))) + ;; integer + (delay endlessh-configuration-delay (default 10000)) + ;; integer + ;; Must be in the range + (length endlessh-configuration-length (default 32)) + ;; integer + (max-clients endlessh-configuration-max-clients (default 4096)) + ;; integer + (port-number endlessh-configuration-port-number (default 2222)) + ;; integer + ;; Allowed values are 0, 1 and 2 + (log-level endlessh-configuration-log-level (default 0))) + +(define (endlessh-config->conf config) + "Convert the CONFIG of type to a config file." + (let* ((family (endlessh-configuration-bind-family config)) + (ipv4 (member 'ipv4 family)) + (ipv6 (member 'ipv6 family)) + (port (endlessh-configuration-port-number config)) + (delay (endlessh-configuration-delay config)) + (length (endlessh-configuration-length config)) + (log-level (endlessh-configuration-log-level config)) + (max-clients (endlessh-configuration-max-clients config)) + (bind + ;; check if both are true (0), or only one of them is present + (if (not (and (equal? ipv4 ipv6) ipv4)) + (if ipv4 4 + (if ipv6 6 + (throw 'endlessh-error + "bind-family must contain at least one value"))) + 0))) + (mixed-text-file "endlessh.conf" + "# Generated by 'endlessh-config'.\n\n" + "Port " (number->string port) "\n" + "Delay " (number->string delay) "\n" + "MaxLineLength " (number->string length) "\n" + "MaxClients " (number->string max-clients) "\n" + "LogLevel " (number->string log-level) "\n" + "BindFamily " (number->string bind) "\n"))) + +(define (endlessh-shepherd-service config) + (shepherd-service + (documentation "Run endlessh tarpit server.") + (provision '(endlessh)) + (start #~(make-forkexec-constructor + (list #$(file-append endlessh "/bin/endlessh") + "-f" #$(endlessh-config->conf config)))) + (stop #~(make-kill-destructor)))) + +(define endlessh-service-type + (service-type + (name 'endlessh) + (description "Run endlessh tarpit server.") + (extensions + (list (service-extension shepherd-root-service-type + (compose list endlessh-shepherd-service)))) + (default-value (endlessh-configuration)))) + + ;;; ;;; WebSSH -- 2.37.3