From patchwork Tue Dec 3 21:15:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 16360 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 37B0117835; Tue, 3 Dec 2019 21:17:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id E6AA21782E for ; Tue, 3 Dec 2019 21:17:39 +0000 (GMT) Received: from localhost ([::1]:58698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFY9-0000ox-DN for patchwork@mira.cbaines.net; Tue, 03 Dec 2019 16:17:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFXf-0000lt-J5 for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icFXb-0002fN-0N for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icFXa-0002ed-CE for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icFXa-00075V-6H for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38478] [PATCH 1/4] ssh: Add 'authenticate-server*' and use it for offloading. References: <20191203210958.20936-1-ludo@gnu.org> In-Reply-To: <20191203210958.20936-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Dec 2019 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38478 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38478@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 38478-submit@debbugs.gnu.org id=B38478.157540778627173 (code B ref 38478); Tue, 03 Dec 2019 21:17:02 +0000 Received: (at 38478) by debbugs.gnu.org; 3 Dec 2019 21:16:26 +0000 Received: from localhost ([127.0.0.1]:41135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFWz-00074B-TE for submit@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFWy-00073m-DE for 38478@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:24 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1icFWi-0001KU-3W; Tue, 03 Dec 2019 16:16:09 -0500 Received: from [102.78.164.116] (port=18308 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1icFWf-0001Km-Pw; Tue, 03 Dec 2019 16:16:06 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 3 Dec 2019 22:15:54 +0100 Message-Id: <20191203211557.21145-1-ludo@gnu.org> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/offload.scm (host-key->type+key): Remove. (open-ssh-session): Replace server authentication code with a call to 'authenticate-server*'. * guix/ssh.scm (host-key->type+key, authenticate-server*): New procedures. --- guix/scripts/offload.scm | 30 ++---------------------------- guix/ssh.scm | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 18473684eb..e81b6c25f2 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -149,19 +149,6 @@ ignoring it~%") (leave (G_ "failed to load machine file '~a': ~s~%") file args)))))) -(define (host-key->type+key host-key) - "Destructure HOST-KEY, an OpenSSH host key string, and return two values: -its key type as a symbol, and the actual base64-encoded string." - (define (type->symbol type) - (and (string-prefix? "ssh-" type) - (string->symbol (string-drop type 4)))) - - (match (string-tokenize host-key) - ((type key x) - (values (type->symbol type) key)) - ((type key) - (values (type->symbol type) key)))) - (define (private-key-from-file* file) "Like 'private-key-from-file', but raise an error that 'with-error-handling' can interpret meaningfully." @@ -203,21 +190,8 @@ private key from '~a': ~a") (build-machine-compression-level machine)))) (match (connect! session) ('ok - ;; Authenticate the server. XXX: Guile-SSH 0.10.1 doesn't know about - ;; ed25519 keys and 'get-key-type' returns #f in that case. - (let-values (((server) (get-server-public-key session)) - ((type key) (host-key->type+key - (build-machine-host-key machine)))) - (unless (and (or (not (get-key-type server)) - (eq? (get-key-type server) type)) - (string=? (public-key->string server) key)) - ;; Key mismatch: something's wrong. XXX: It could be that the server - ;; provided its Ed25519 key when we where expecting its RSA key. - (leave (G_ "server at '~a' returned host key '~a' of type '~a' \ -instead of '~a' of type '~a'~%") - (build-machine-name machine) - (public-key->string server) (get-key-type server) - key type))) + ;; Make sure the server's key is what we expect. + (authenticate-server* session (build-machine-host-key machine)) (let ((auth (userauth-public-key! session private))) (unless (eq? 'success auth) diff --git a/guix/ssh.scm b/guix/ssh.scm index 5fd3c280e8..f34e71392b 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -37,6 +37,8 @@ #:use-module (ice-9 format) #:use-module (ice-9 binary-ports) #:export (open-ssh-session + authenticate-server* + remote-inferior remote-daemon-channel connect-to-remote-daemon @@ -60,6 +62,41 @@ (define %compression "zlib@openssh.com,zlib") +(define (host-key->type+key host-key) + "Destructure HOST-KEY, an OpenSSH host key string, and return two values: +its key type as a symbol, and the actual base64-encoded string." + (define (type->symbol type) + (and (string-prefix? "ssh-" type) + (string->symbol (string-drop type 4)))) + + (match (string-tokenize host-key) + ((type key x) + (values (type->symbol type) key)) + ((type key) + (values (type->symbol type) key)))) + +(define (authenticate-server* session key) + "Make sure the server for SESSION has the given KEY, where KEY is a string +such as \"ssh-ed25519 AAAAC3Nz… root@example.org\". Raise an exception if the +actual key does not match." + (let-values (((server) (get-server-public-key session)) + ((type key) (host-key->type+key key))) + (unless (and (or (not (get-key-type server)) + (eq? (get-key-type server) type)) + (string=? (public-key->string server) key)) + ;; Key mismatch: something's wrong. XXX: It could be that the server + ;; provided its Ed25519 key when we where expecting its RSA key. XXX: + ;; Guile-SSH 0.10.1 doesn't know about ed25519 keys and 'get-key-type' + ;; returns #f in that case. + (raise (condition + (&message + (message (format #f (G_ "server at '~a' returned host key \ +'~a' of type '~a' instead of '~a' of type '~a'~%") + (session-get session 'host) + (public-key->string server) + (get-key-type server) + key type)))))))) + (define* (open-ssh-session host #:key user port identity (compression %compression) (timeout 3600)) From patchwork Tue Dec 3 21:15:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 16363 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 432D217835; Tue, 3 Dec 2019 21:44:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id DD03C1782E for ; Tue, 3 Dec 2019 21:44:37 +0000 (GMT) Received: from localhost ([::1]:59150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFyF-0004H4-EW for patchwork@mira.cbaines.net; Tue, 03 Dec 2019 16:44:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39719) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFXg-0000ls-Is for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icFXb-0002gQ-Dj for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icFXb-0002g6-9U for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icFXb-00075k-5U for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38478] [PATCH 2/4] ssh: Always authenticate the server [security fix]. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Dec 2019 21:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38478 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38478@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 38478-submit@debbugs.gnu.org id=B38478.157540778727192 (code B ref 38478); Tue, 03 Dec 2019 21:17:03 +0000 Received: (at 38478) by debbugs.gnu.org; 3 Dec 2019 21:16:27 +0000 Received: from localhost ([127.0.0.1]:41140 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFX0-00074L-L6 for submit@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFWy-00073n-Fi for 38478@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:25 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1icFWo-0001Nv-19; Tue, 03 Dec 2019 16:16:17 -0500 Received: from [102.78.164.116] (port=18308 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1icFWi-0001Km-OE; Tue, 03 Dec 2019 16:16:12 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 3 Dec 2019 22:15:55 +0100 Message-Id: <20191203211557.21145-2-ludo@gnu.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203211557.21145-1-ludo@gnu.org> References: <20191203211557.21145-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Until now, users of 'open-ssh-session', including "guix deploy" and "GUIX_DAEMON_SOCKET=ssh://…" (but not "guix offload"), would not authenticate the SSH server they're talking to. * guix/ssh.scm (open-ssh-session): Call 'authenticate-server'. --- guix/ssh.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/guix/ssh.scm b/guix/ssh.scm index f34e71392b..519c723155 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -125,6 +125,17 @@ Throw an error on failure." (match (connect! session) ('ok + ;; Authenticate against ~/.ssh/known_hosts. + (match (authenticate-server session) + ('ok #f) + (reason + (raise (condition + (&message + (message (format #f (G_ "failed to authenticate \ +server at '~a': ~a") + (session-get session 'host) + reason))))))) + ;; Use public key authentication, via the SSH agent if it's available. (match (userauth-public-key/auto! session) ('success From patchwork Tue Dec 3 21:15:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 16364 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1E7B817835; Tue, 3 Dec 2019 21:46:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id D6A6E1782E for ; Tue, 3 Dec 2019 21:46:30 +0000 (GMT) Received: from localhost ([::1]:59174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icG05-0004yQ-6F for patchwork@mira.cbaines.net; Tue, 03 Dec 2019 16:46:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39687) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFXd-0000km-KT for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icFXb-0002fi-2A for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icFXa-0002ez-PS for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icFXa-00075c-L8 for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38478] [PATCH 3/4] ssh: 'open-ssh-session' can be passed the expected host key. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Dec 2019 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38478 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38478@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 38478-submit@debbugs.gnu.org id=B38478.157540778627180 (code B ref 38478); Tue, 03 Dec 2019 21:17:02 +0000 Received: (at 38478) by debbugs.gnu.org; 3 Dec 2019 21:16:26 +0000 Received: from localhost ([127.0.0.1]:41138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFX0-00074E-AX for submit@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFWy-00073o-Ga for 38478@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:25 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1icFWq-0001Or-6K; Tue, 03 Dec 2019 16:16:19 -0500 Received: from [102.78.164.116] (port=18308 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1icFWo-0001Km-B1; Tue, 03 Dec 2019 16:16:15 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 3 Dec 2019 22:15:56 +0100 Message-Id: <20191203211557.21145-3-ludo@gnu.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203211557.21145-1-ludo@gnu.org> References: <20191203211557.21145-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/ssh.scm (open-ssh-session): Add #:host-key parameter. Pass #:knownhosts to 'make-session'. When HOST-KEY is true, call 'authenticate-server*' instead of 'authenticate-server'. --- guix/ssh.scm | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/guix/ssh.scm b/guix/ssh.scm index 519c723155..291ce20b61 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -98,14 +98,20 @@ actual key does not match." key type)))))))) (define* (open-ssh-session host #:key user port identity + host-key (compression %compression) (timeout 3600)) "Open an SSH session for HOST and return it. IDENTITY specifies the file name of a private key to use for authenticating with the host. When USER, PORT, or IDENTITY are #f, use default values or whatever '~/.ssh/config' -specifies; otherwise use them. Install TIMEOUT as the maximum time in seconds -after which a read or write operation on a channel of the returned session is -considered as failing. +specifies; otherwise use them. + +When HOST-KEY is true, it must be a string like \"ssh-ed25519 AAAAC3Nz… +root@example.org\"; the server is authenticated and an error is raised if its +host key is different from HOST-KEY. + +Install TIMEOUT as the maximum time in seconds after which a read or write +operation on a channel of the returned session is considered as failing. Throw an error on failure." (let ((session (make-session #:user user @@ -115,6 +121,11 @@ Throw an error on failure." #:timeout 10 ;seconds ;; #:log-verbosity 'protocol + ;; Prevent libssh from reading + ;; ~/.ssh/known_hosts when the caller provides + ;; a HOST-KEY to match against. + #:knownhosts (and host-key "/dev/null") + ;; We need lightweight compression when ;; exchanging full archives. #:compression compression @@ -125,16 +136,20 @@ Throw an error on failure." (match (connect! session) ('ok - ;; Authenticate against ~/.ssh/known_hosts. - (match (authenticate-server session) - ('ok #f) - (reason - (raise (condition - (&message - (message (format #f (G_ "failed to authenticate \ + (if host-key + ;; Make sure the server's key is what we expect. + (authenticate-server* session host-key) + + ;; Authenticate against ~/.ssh/known_hosts. + (match (authenticate-server session) + ('ok #f) + (reason + (raise (condition + (&message + (message (format #f (G_ "failed to authenticate \ server at '~a': ~a") - (session-get session 'host) - reason))))))) + (session-get session 'host) + reason)))))))) ;; Use public key authentication, via the SSH agent if it's available. (match (userauth-public-key/auto! session) From patchwork Tue Dec 3 21:15:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 16365 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9358017835; Tue, 3 Dec 2019 21:47:43 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 4AF5F1782E for ; Tue, 3 Dec 2019 21:47:43 +0000 (GMT) Received: from localhost ([::1]:59190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icG1E-0005T5-Ka for patchwork@mira.cbaines.net; Tue, 03 Dec 2019 16:47:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39766) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icFXm-0000oe-Nk for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icFXd-0002kw-QY for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:11 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35172) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icFXb-0002hA-Pb for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icFXb-00075r-LY for guix-patches@gnu.org; Tue, 03 Dec 2019 16:17:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38478] [PATCH 4/4] machine: ssh: can include the host key. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Dec 2019 21:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38478 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38478@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 38478-submit@debbugs.gnu.org id=B38478.157540778827202 (code B ref 38478); Tue, 03 Dec 2019 21:17:03 +0000 Received: (at 38478) by debbugs.gnu.org; 3 Dec 2019 21:16:28 +0000 Received: from localhost ([127.0.0.1]:41142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFX2-00074f-0R for submit@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57927) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icFX0-00073q-8s for 38478@debbugs.gnu.org; Tue, 03 Dec 2019 16:16:26 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1icFWr-0001QB-Eo; Tue, 03 Dec 2019 16:16:19 -0500 Received: from [102.78.164.116] (port=18308 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1icFWq-0001Km-Pv; Tue, 03 Dec 2019 16:16:17 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 3 Dec 2019 22:15:57 +0100 Message-Id: <20191203211557.21145-4-ludo@gnu.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203211557.21145-1-ludo@gnu.org> References: <20191203211557.21145-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/machine/ssh.scm ()[host-key]: New field. (machine-ssh-session): Pass #:host-key to 'open-ssh-session'. * doc/guix.texi (Invoking guix deploy): Document it. --- doc/guix.texi | 12 ++++++++++++ gnu/machine/ssh.scm | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2da1ecd64c..e6e015ad3e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -26412,6 +26412,18 @@ keyring. @item @code{identity} (default: @code{#f}) If specified, the path to the SSH private key to use to authenticate with the remote host. + +@item @code{host-key} (default: @code{#f}) +This should be the SSH host key of the machine, which looks like this: + +@example +ssh-ed25519 AAAAC3Nz@dots{} root@@example.org +@end example + +When @code{host-key} is @code{#f}, the server is authenticated against +the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh} +client does. + @end table @end deftp diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 6e3ed0e092..23ae917b79 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -54,6 +54,7 @@ machine-ssh-configuration-authorize? machine-ssh-configuration-port machine-ssh-configuration-user + machine-ssh-configuration-host-key machine-ssh-configuration-session)) ;;; Commentary: @@ -87,6 +88,8 @@ (identity machine-ssh-configuration-identity ; path to a private key (default #f)) (session machine-ssh-configuration-session ; session + (default #f)) + (host-key machine-ssh-configuration-host-key ; #f | string (default #f))) (define (machine-ssh-session machine) @@ -98,11 +101,13 @@ one from the configuration's parameters if one was not provided." (let ((host-name (machine-ssh-configuration-host-name config)) (user (machine-ssh-configuration-user config)) (port (machine-ssh-configuration-port config)) - (identity (machine-ssh-configuration-identity config))) + (identity (machine-ssh-configuration-identity config)) + (host-key (machine-ssh-configuration-host-key config))) (open-ssh-session host-name #:user user #:port port - #:identity identity))))) + #:identity identity + #:host-key host-key))))) ;;;