ssh: Always authenticate the server [security fix].
authorLudovic Courtès <ludo@gnu.org>
Tue, 3 Dec 2019 20:41:54 +0000 (21:41 +0100)
committerLudovic Courtès <ludo@gnu.org>
Wed, 4 Dec 2019 17:16:08 +0000 (18:16 +0100)
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

index f34e713..519c723 100644 (file)
@@ -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