···
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
20
-
knownHostsFile = pkgs.writeText "ssh_known_hosts" (
21
-
flip concatMapStrings knownHosts (h: ''
22
-
${concatStringsSep "," h.hostNames} ${if h.publicKey != null then h.publicKey else readFile h.publicKeyFile}
20
+
knownHostsFile = pkgs.runCommand "ssh_known_hosts" {} ''
21
+
#!${pkgs.bash}/bin/bash
22
+
${flip concatMapStrings knownHosts (h: ''
23
+
pubkeyfile=${builtins.toFile "host.pub" (if h.publicKey == null then readFile h.publicKeyFile else h.publicKey)}
24
+
${pkgs.gnused}/bin/sed 's/^/${concatStringsSep "," h.hostNames} /' $pubkeyfile >> $out
···
The public key data for the host. You can fetch a public key
from a running SSH server with the <command>ssh-keyscan</command>
259
+
command. The public key should not include any host names, only
260
+
the key type and the key itself. It is allowed to add several
261
+
lines here, each line will be treated as type/key pair and the
262
+
host names will be prepended to each line.
publicKeyFile = mkOption {
···
The path to the public key file for the host. The public
key file is read at build time and saved in the Nix store.
You can fetch a public key file from a running SSH server
267
-
with the <command>ssh-keyscan</command> command.
272
+
with the <command>ssh-keyscan</command> command. The content
273
+
of the file should follow the same format as described for
274
+
the <literal>publicKey</literal> option.