OpenSSH:控制端口转发?

是否有可能限制端口转发与OpenSSH? 我想让用户ssh -R在端口6000..7000 ,但我想阻止ssh -Dssh -L

您感兴趣的sshd_configconfiguration指令包括:

 AllowTcpForwarding PermitOpen 

在限制允许的端口转发types方面似乎没有任何粒度。

但是,请注意AllowTCPForwarding选项的文档:

  AllowTcpForwarding Specifies whether TCP forwarding is permitted. The default is ``yes''. Note that disabling TCP forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders. 

这个概念是,如果你的用户拥有shell访问权限,那么他们使用netcat等实用工具login后就可以设置自己的转发,这是微不足道的。 这将绕过任何sshdconfiguration设置。

还有使用iptables可以让你对允许连接和/或转发的端口进行细化控制。

http://www.manpagez.com/man/8/sshd/searchPermitOpen

我做:

Match User Blah
PermitOpen BlahComputer:3389