all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: George myglc2 Clemmer <myglc2@gmail.com>
Cc: help-guix <help-guix@gnu.org>
Subject: Re: How best to set host key in vm
Date: Fri, 09 Feb 2018 12:02:59 +0100	[thread overview]
Message-ID: <87eflu2zoc.fsf@gnu.org> (raw)
In-Reply-To: <86tvut25uf.fsf@gmail.com> (George myglc's message of "Tue, 06 Feb 2018 15:58:16 -0500")

Heya,

George myglc2 Clemmer <myglc2@gmail.com> skribis:

> I want to set the host key in 'guix system vm-image' so that updating a
> VM config does not break that VM's host key entry in my client machine
> ~/.ssh/knownhosts files.  AFAIK there is no direct way to do this. I
> tried this ...
>
>   (services (cons*
>   [...]
> 	     (extra-special-file "/etc/ssh/ssh_host_ed25519_key"
> 				 (local-file "ssh_host_ed25519_key"))
> 	     (extra-special-file "/etc/ssh/ssh_host_ed25519_key.pub"
>    				 (local-file "ssh_host_ed25519_key.pub"))
>   )
>
> ... which does work but naturally throws errors ...
>
> localhost sshd[236]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> localhost sshd[236]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
> localhost sshd[236]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

You should *not* do that, indeed, because the private key file ends up
in the store, and every file in the store is world-readable.  There’s no
way around it, currently at least.

The recommendation in this case is to use “out-of-band” storage—i.e.,
have the secrets stored in a place other than the store.

For example, you could have an activation snippet that copies secret
files directly to /etc, along these lines (untested):

  (simple-service 'copy-private-key activation-service-type
                  (with-imported-modules '((guix build utils))
                    #~(begin
                        (use-modules (guix build utils))
                        (mkdir-p "/etc/ssh")
                        (copy-file "/root/secrets/ssh_host_ed25519_key"
                                   "/etc/ssh/ssh_host_ed25519_key'))))

That means you have to arrange for /root/secrets/ssh_host_ed25519_key to
exist in the first place, but that’s pretty much all we can do.

HTH!

Ludo’.

  reply	other threads:[~2018-02-09 11:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 20:58 How best to set host key in vm George myglc2 Clemmer
2018-02-09 11:02 ` Ludovic Courtès [this message]
2018-02-09 17:55   ` George myglc2 Clemmer
2018-02-15 14:51     ` Ludovic Courtès
2018-02-15 15:21       ` George myglc2 Clemmer
2018-02-16 10:17         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eflu2zoc.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=help-guix@gnu.org \
    --cc=myglc2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.