An SSH login is more than a shell. With -L, -R and -D a user can turn your server into a tunnel into the network behind it. On a bastion or a file drop, I do not want that.
One line in sshd_config covers it:
DisableForwarding yes
The man page says it disables all forwarding: X11, the ssh agent, TCP and Unix sockets, and it overrides the separate options like AllowTcpForwarding and AllowAgentForwarding. That is easier than setting four options and hoping you did not miss one.
It works inside a Match block too, so you can keep forwarding for yourself and block it for the rest:
Match User *,!alice
DisableForwarding yes
Then sudo sshd -t and a restart. A quick test from a client: ssh -N -L 8080:127.0.0.1:80 [email protected] should now print a refusal as soon as you use the forward.
The man page is honest about the limit. If a user has a normal shell, they can install their own forwarder, so blocking tunnels only really holds together with a restricted account, like an SFTP-only user or a forced command. And if you jump through this host with ProxyJump, that also counts as forwarding and stops working.
Further reading: sshd_config man page