Skip to content

Commit 879f627

Browse files
authored
Prevent nfs being mounted by tunnelling/forwarding through login node (#595)
* prevent nfs tunnelling through login node * bump nfs role * disable ssh forwarding by default
1 parent ede561f commit 879f627

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

ansible/roles/sshd/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Configure sshd.
55
## Role variables
66

77
- `sshd_password_authentication`: Optional bool. Whether to enable password login. Default `false`.
8+
- `sshd_disable_forwarding`: Optional bool. Whether to disable all forwarding features (X11, ssh-agent, TCP and StreamLocal). Default `true`.
89
- `sshd_conf_src`: Optional string. Path to sshd configuration template. Default is in-role template.
910
- `sshd_conf_dest`: Optional string. Path to destination for sshd configuration file. Default is `/etc/ssh/sshd_config.d/10-ansible.conf` which overides `50-{cloud-init,redhat}` files, if present.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
sshd_password_authentication: false
2+
sshd_disable_forwarding: true
23
sshd_conf_src: sshd.conf.j2
34
sshd_conf_dest: /etc/ssh/sshd_config.d/10-ansible.conf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# {{ ansible_managed }}
22
PasswordAuthentication {{ 'yes' if sshd_password_authentication | bool else 'no' }}
3+
DisableForwarding {{ 'yes' if sshd_disable_forwarding | bool else 'no' }}

docs/networks.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ as an SSH proxy to access the other nodes, this can create problems in recoverin
1414
the cluster if the login node is unavailable and can make Ansible problems harder
1515
to debug.
1616

17+
> [!WARNING]
18+
> If home directories are on a shared filesystem with no authentication (such
19+
> as the default NFS share) then the network(s) the fileserver is attached to
20+
> form a security boundary. If an untrusted user can access these networks they
21+
> could mount the home directories setting any desired uid/gid.
22+
>
23+
> Ensure there is no external access to these networks and that no untrusted
24+
> instances are attached to them.
25+
1726
This page describes supported configurations and how to implement them using
1827
the OpenTofu variables. These will normally be set in
1928
`environments/site/tofu/terraform.tfvars` for the site base environment. If they
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
nfs_configurations:
2+
- comment: Export /exports/home from Slurm control node as /home
3+
nfs_enable:
4+
server: "{{ inventory_hostname in groups['control'] }}"
5+
# Don't mount share on server where it is exported from...
6+
# Could do something like `nfs_clients: "{{ 'nfs_servers' not in group_names }}"` instead.
7+
clients: "{{ inventory_hostname in groups['cluster'] and inventory_hostname not in groups['control'] }}"
8+
nfs_server: "{{ nfs_server_default }}"
9+
nfs_export: "/exports/home" # assumes skeleton TF is being used
10+
nfs_client_mnt_point: "/home"
11+
12+
# EXPERIMENTAL - not generally secure
13+
- comment: Export /exports/cluster from Slurm control node
14+
nfs_enable:
15+
server: "{{ inventory_hostname in groups['control'] }}"
16+
clients: false
17+
nfs_export: "/exports/cluster"

environments/common/inventory/group_vars/all/nfs.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ nfs_configurations:
1616
nfs_export: "/exports/home" # assumes skeleton TF is being used
1717
nfs_client_mnt_point: "/home"
1818

19-
- comment: Export /exports/cluster from Slurm control node
20-
nfs_enable:
21-
server: "{{ inventory_hostname in groups['control'] }}"
22-
clients: false
23-
nfs_export: "/exports/cluster"
19+
# Set 'secure' to prevent tunneling nfs mounts
20+
# Cannot set 'root_squash' due to home directory creation
21+
nfs_export_options: 'rw,secure,no_root_squash'

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
roles:
33
- src: stackhpc.nfs
4-
version: v23.12.1 # Tolerate state nfs file handles
4+
version: v25.2.1
55
- src: https://github.com/stackhpc/ansible-role-openhpc.git
66
version: v0.27.0
77
name: stackhpc.openhpc

0 commit comments

Comments
 (0)