diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-02-11 22:06:12 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-02-12 07:51:24 +0530 |
commit | ed3fd9a36f174d8001b1693fe4d0e2761febeb56 (patch) | |
tree | 90244f90d46c266282b239704ef170d78be7d599 /hosts/lia/modules | |
parent | d87edb6024132db442600c76b6db1f49a01ed0e2 (diff) |
hosts/lia/sshfwd/lia.sinanmohd.com: init
Diffstat (limited to 'hosts/lia/modules')
-rw-r--r-- | hosts/lia/modules/sshfwd.nix | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/hosts/lia/modules/sshfwd.nix b/hosts/lia/modules/sshfwd.nix index dac2d71..f5f7526 100644 --- a/hosts/lia/modules/sshfwd.nix +++ b/hosts/lia/modules/sshfwd.nix @@ -2,7 +2,9 @@ mkFwdSrv = { local_port, remote_port, + remote_user, remote ? "sinanmohd.com", + ssh_port ? 22, key ? config.sops.secrets."sshfwd/${remote}".path, }: { "sshfwd-${toString local_port}-${remote}:${toString remote_port}" = { @@ -18,7 +20,7 @@ path = [ pkgs.openssh ]; script = '' echo -n "Forwarding port ${toString local_port}" - exec ssh -N lia@${remote} \ + exec ssh -N ${remote_user}@${remote} -p ${toString ssh_port} \ -R 0.0.0.0:${toString remote_port}:127.0.0.1:${toString local_port} \ -i ${key} ''; @@ -26,8 +28,20 @@ }; in { sops.secrets."sshfwd/sinanmohd.com" = {}; + sops.secrets."sshfwd/lia.sinanmohd.com" = {}; environment.systemPackages = with pkgs; [ openssh ]; systemd.services - = mkFwdSrv { local_port = 22; remote_port = 2222; }; + = (mkFwdSrv { + local_port = 22; + remote_user = "lia"; + remote_port = 2222; + }) // + (mkFwdSrv { + local_port = 22; + remote_port = 22; + ssh_port = 23; + remote_user = "root"; + remote = "lia.sinanmohd.com"; + }); } |