]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/networking/ssh.nix
doc: explain tributes in naming the machines
[sourcephile-nix.git] / machines / losurdo / networking / ssh.nix
1 { pkgs, lib, config, machines, ... }:
2 let
3 inherit (config.security) gnupg;
4 inherit (config.users) users;
5 initrdKey = "initrd/ssh.key";
6 in
7 {
8 systemd.services.ssh-mermet-reverse = {
9 after = [ "network-online.target" ];
10 wantedBy = [ "multi-user.target" ];
11 serviceConfig = {
12 Type = "simple";
13 ExecStart = ''${pkgs.openssh}/bin/ssh -v -g -N -T \
14 -o ServerAliveInterval=10 \
15 -o ExitOnForwardFailure=yes \
16 -R *:10022:localhost:22 \
17 ${machines.mermet.extraArgs.ipv4}
18 '';
19 Restart = "always";
20 RestartSec = "5s";
21 };
22 };
23 /*
24 installer.ssh-nixos.script = lib.mkBefore ''
25 # Send the SSH key of the initrd
26 gpg --decrypt '${gnupg.store}/${initrdKey}.gpg' |
27 ssh '${config.installer.ssh-nixos.target}' \
28 install -D -m 400 -o root -g root /dev/stdin /root/${initrdKey}
29 '';
30 */
31 boot.initrd.network.ssh = {
32 enable = true;
33 # To prevent ssh from freaking out because a different host key is used,
34 # a different port for dropbear is useful
35 # (assuming the same host has also a normal sshd running)
36 port = 2222;
37 authorizedKeys = users.root.openssh.authorizedKeys.keys;
38 hostKeys = [ "/root/${initrdKey}" ];
39 };
40 }