summaryrefslogtreecommitdiff
path: root/hosts/lia/modules
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/lia/modules')
-rw-r--r--hosts/lia/modules/sshfwd.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/hosts/lia/modules/sshfwd.nix b/hosts/lia/modules/sshfwd.nix
new file mode 100644
index 0000000..f86238b
--- /dev/null
+++ b/hosts/lia/modules/sshfwd.nix
@@ -0,0 +1,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}
+ '';
+ };
+}