# /etc/ssh/sshd_config.d/50-alumnos.conf # Requiere `Include /etc/ssh/sshd_config.d/*.conf` en sshd_config (por defecto en Ubuntu 22.04+). # # Los alumnos solo pueden abrir reenvíos inversos a sockets Unix. Sin shell, sin TCP, # sin agente. Las claves las gestiona el administrador (no ~/.ssh/authorized_keys). Match Group alumnos AuthorizedKeysFile /etc/ssh/authorized_keys/%u PubkeyAuthentication yes PasswordAuthentication no KbdInteractiveAuthentication no MaxAuthTries 3 MaxSessions 2 # OJO: `AllowTcpForwarding no` desactiva TAMBIÉN el reenvío remoto por socket Unix # (OpenSSH 9.2: "port forwarding refused"), por eso se usa `remote`. Los reenvíos TCP # se anulan con PermitListen a un puerto privilegiado que un usuario sin privilegios # no puede enlazar; el socket Unix no se ve afectado. Verificado en Debian 12 / OpenSSH 9.2. AllowTcpForwarding remote PermitListen 127.0.0.1:1 AllowStreamLocalForwarding remote GatewayPorts no StreamLocalBindUnlink yes # permite reconectar sobre el mismo socket StreamLocalBindMask 0117 # socket rw para propietario y grupo (nginxsock) PermitTTY no X11Forwarding no AllowAgentForwarding no PermitTunnel no ForceCommand /bin/false ClientAliveInterval 30 # detecta túneles muertos y libera el socket ClientAliveCountMax 3