ssh-tunnel.nix (679B)
1 { pkgs, username, domain, ... }: 2 3 { 4 systemd.services.reverse-ssh-tunnel = { 5 description = "Persistent Reverse SSH Tunnel"; 6 after = [ "network-online.target" ]; 7 wants = [ "network-online.target" ]; 8 wantedBy = [ "multi-user.target" ]; 9 10 serviceConfig = { 11 ExecStart = "${pkgs.openssh}/bin/ssh -NTg -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=accept-new -p 55012 -i /home/${username}/vault/docs/secure/ssh-key-2022-02-16.key -R 55013:localhost:22 ${username}@${domain}"; 12 Restart = "always"; 13 RestartSec = "10s"; 14 User = "${username}"; 15 }; 16 }; 17 18 environment.systemPackages = with pkgs; [ openssh ]; 19 }