From 7bb35b9e407422312c171802c7f5e583f353ba28 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sun, 11 Feb 2024 20:17:49 +0530 Subject: hosts/kay,lia/sshfwd: init --- hosts/lia/modules/sshfwd.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hosts/lia/modules/sshfwd.nix (limited to 'hosts/lia/modules/sshfwd.nix') 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} + ''; + }; +} -- cgit v1.2.3