blob: e9723a7e5660189cf7c0a84eec0abf21a46d4dd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
{ config, lib, pkgs, ... }:
with lib; let
cfg = config.local;
in
{
config = {
security.pam = {
oath = {
usersFile = "/var/trust/auth/users.oath";
digits = 6;
window = 30;
};
services.sshd.oathAuth = true;
};
services.openssh = {
enable = true;
openFirewall = false;
ports = [ 2234 ];
startWhenNeeded = true;
forwardX11 = true;
permitRootLogin = "no";
passwordAuthentication = true; # Necesario para oath, no reemplaza a oath
hostKeys = [
{
bits = 4096;
path = "/etc/ssh/ssh_host_rsa_key";
type = "rsa";
}
{
path = "/etc/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
#TODO: Desfasar, inseguro
{
path = "/etc/ssh/ssh_host_ecdsa_key";
type = "ecdsa";
}
];
extraConfig = ''
# User 'tunnel' has no password. Use PAM OATH
# and connect with -N, forward with -R.
Match User tunnel
AllowTcpForwarding remote
AllowStreamLocalForwarding no
X11Forwarding no
PermitTunnel no
GatewayPorts no
AllowAgentForwarding no
PermitOpen none
PermitListen 60220 60221 60222 60223 60224 60225 60226 60227 60228 60229
Banner ${pkgs.writeText "tunnel-banner" ''
This is a reverse tunnel
''}
'';
};
networking.firewall.allowedTCPPorts = [ 2234 ];
users.users.tunnel = {
uid = 1100;
group = "nogroup";
isSystemUser = true;
# Requiere oath
password = "tunnel";
home = "/var/empty";
shell = "${pkgs.coreutils}/bin/true";
};
};
}
|