From a2ef2bcbfd75593a865e726b014594a73aa0e441 Mon Sep 17 00:00:00 2001 From: Sergey Trofimov Date: Fri, 14 Mar 2025 16:06:54 +0100 Subject: machine: hetzner: Allow connections using ssh-agent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/machine/hetzner.scm (): Add ssh-public-key. * doc/guix.texi (System Configuration)[hetzner-configuration]: Document it. Change-Id: I7354ead508b1a4819534c6b22ba1f089749927c2 Signed-off-by: Ludovic Courtès Modified-by: Ludovic Courtès --- gnu/machine/hetzner.scm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'gnu') diff --git a/gnu/machine/hetzner.scm b/gnu/machine/hetzner.scm index bc8d2efbd34..e8484e4d51e 100644 --- a/gnu/machine/hetzner.scm +++ b/gnu/machine/hetzner.scm @@ -77,6 +77,7 @@ hetzner-configuration-location hetzner-configuration-server-type hetzner-configuration-ssh-key + hetzner-configuration-ssh-public-key hetzner-configuration? hetzner-environment-type)) @@ -204,20 +205,24 @@ Have you run 'guix archive --generate-key'?") (default "fsn1")) (server-type hetzner-configuration-server-type ; string (default "cx42")) - (ssh-key hetzner-configuration-ssh-key)) ; string + (ssh-public-key hetzner-configuration-ssh-public-key ; public-key | string + (thunked) + (default (public-key-from-file (hetzner-configuration-ssh-key this-hetzner-configuration))) + (sanitize + (lambda (value) + (if (string? value) (public-key-from-file value) value)))) + (ssh-key hetzner-configuration-ssh-key + (default #f))) ; #f | string (define (hetzner-configuration-ssh-key-fingerprint config) "Return the SSH public key fingerprint of CONFIG as a string." - (and-let* ((file-name (hetzner-configuration-ssh-key config)) - (privkey (private-key-from-file file-name)) - (pubkey (private-key->public-key privkey)) + (and-let* ((pubkey (hetzner-configuration-ssh-public-key config)) (hash (get-public-key-hash pubkey 'md5))) (bytevector->hex-string hash))) (define (hetzner-configuration-ssh-key-public config) "Return the SSH public key of CONFIG as a string." - (and-let* ((ssh-key (hetzner-configuration-ssh-key config)) - (public-key (public-key-from-file ssh-key))) + (let ((public-key (hetzner-configuration-ssh-public-key config))) (format #f "ssh-~a ~a" (get-key-type public-key) (public-key->string public-key)))) -- cgit v1.3