From 1b62ce024043399d3be998324c2d66e566a5f14f Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Fri, 11 Sep 2020 20:27:40 +0200 Subject: [PATCH] [fix] Reduce right given to ynh users with ssh (#1050) * [fix] Avoid ynh user to be able to use X11 forwarding * [fix] Avoid some bad situations * [fix] Remove chroot restrictions and x11 authorization * Update comments Co-authored-by: Alexandre Aubin --- data/templates/ssh/sshd_config | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/data/templates/ssh/sshd_config b/data/templates/ssh/sshd_config index bd3efdef3..84f06d4e5 100644 --- a/data/templates/ssh/sshd_config +++ b/data/templates/ssh/sshd_config @@ -66,12 +66,19 @@ AcceptEnv LANG LC_* # SFTP stuff Subsystem sftp internal-sftp -Match User sftpusers - ForceCommand internal-sftp - ChrootDirectory /home/%u - AllowTcpForwarding no - GatewayPorts no - X11Forwarding no + +# Forbid users from using their account SSH as a VPN (even if SSH login is disabled) +AllowTcpForwarding no +AllowStreamLocalForwarding no + +# Disable .ssh/rc, which could be edited (e.g. from Nextcloud or whatever) by users to execute arbitrary commands even if SSH login is disabled +PermitUserRC no + +Match User admin,root + AllowTcpForwarding yes + AllowStreamLocalForwarding yes + PermitUserRC yes + # root login is allowed on local networks # It's meant to be a backup solution in case LDAP is down and