summaryrefslogtreecommitdiff
path: root/hosts/lia/modules/sshfwd.nix
blob: f86238b3a7f9653a5b0fec044443814508964577 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{ pkgs, config, ... }: {
  sops.secrets."sshfwd/kay" = {};

  environment.systemPackages = with pkgs; [ openssh ];
  systemd.services."sshfwd" = {
    description = "Forwarding port 22 to the Internet";
    wantedBy = [ "multi-user.target" ];
    after = [ "network-online.target" ];
    wants = [ "network-online.target" ];
    # restart rather than stop+start this unit to prevent the
    # network from dying during switch-to-configuration.
    stopIfChanged = false;

    path = [ pkgs.openssh ];
    script = ''
      echo -n "Forwarding port 22"
      exec ssh -N lia@sinanmohd.com \
          -R 0.0.0.0:2222:127.0.0.1:22 \
          -i ${config.sops.secrets."sshfwd/kay".path}
    '';
  };
}