test
This commit is contained in:
parent
03c20a3bd8
commit
562180961e
5 changed files with 48 additions and 4 deletions
36
modules/systemd.nix
Normal file
36
modules/systemd.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
autossh
|
||||
];
|
||||
|
||||
systemd.services.autossh-redbot = {
|
||||
description = "Persistent SSH Tunnel to Cloud Server";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
User = "cobray";
|
||||
Group = "cobray";
|
||||
Restart = "always";
|
||||
RestartSec = 30;
|
||||
EnvironmentFile = "/home/cobray/.secrets/autossh-redbot.conf";
|
||||
Environment = [
|
||||
"AUTOSSH_GATETIME=0"
|
||||
"AUTOSSH_POLL=60"
|
||||
"AUTOSSH_FIRST_POLL=30"
|
||||
"AUTOSSH_PORT=0"
|
||||
];
|
||||
ExecStart = ''
|
||||
${pkgs.autossh}/bin/autossh -M 0 -N \
|
||||
-o "ServerAliveInterval 60" \
|
||||
-o "ServerAliveCountMax 3" \
|
||||
-o "ExitOnForwardFailure=yes" \
|
||||
-o "ConnectTimeout=10" \
|
||||
-R "0.0.0.0:$REMOTE_PORT:localhost:$LOCAL_PORT" \
|
||||
root@$REMOTE_HOST
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue