{ pkgs, lib, config, machines, ... }: let inherit (config.security) gnupg; inherit (config.users) users; in { systemd.services.ssh-mermet-reverse = { after = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; # Require services.openssh.gatewayPorts = "clientspecified"; # on the target. ExecStart = ''${pkgs.openssh}/bin/ssh -v -g -N -T \ -o ServerAliveInterval=10 \ -o ExitOnForwardFailure=yes \ -R *:10022:localhost:22 \ ${machines.mermet.extraArgs.ipv4} ''; Restart = "always"; RestartSec = "5s"; }; }; boot.initrd.network.ssh = { enable = true; port = 2222; authorizedKeys = users.root.openssh.authorizedKeys.keys; hostKeys = [ "/root/initrd/ssh.key" ]; }; programs.ssh = { extraConfig = '' Compression = yes ''; }; services.upnpc.redirections = [ { port = 22; protocol = "TCP"; } # SSH { port = 2222; protocol = "TCP"; } # SSH (boot) { port = 60000; protocol = "UDP"; } # Mosh { port = 60001; protocol = "UDP"; } # Mosh { port = 60002; protocol = "UDP"; } # Mosh { port = 60003; protocol = "UDP"; } # Mosh ]; }