-1 ssh ssh-tunnel ubuntu-16.04
在 ubuntu 16.04.3 / OpenSSH_7.2p2 上,通过在 /etc/ssh/sshd_config 中设置这些值来全局禁用隧道没有效果,动态/本地隧道仍然有效
AllowAgentForwarding no
AllowTcpForwarding no
AllowStreamLocalForwarding no
PermitOpen none
PermitTunnel no
X11Forwarding no
Run Code Online (Sandbox Code Playgroud)
更新:我只能通过对选定用户使用“匹配”来使其工作
Match User zuser
AllowTcpForwarding no
X11Forwarding no
AllowAgentForwarding no
AllowStreamLocalForwarding no
PermitOpen none
PermitTunnel no
Run Code Online (Sandbox Code Playgroud)
OpenSSH的使用时,会意外地应用设置Match
和不使用时不应用设置Match
,如果在配置一些早期的位置还有另外一个Match block
。
以下示例演示了这一点:
Match Group sudo
# this is applied to sudo members
ClientAliveInterval 20
# this is applied to sudo members
AllowTcpForwarding yes
# one might assume that the Match block has ended here - it did not
# the following is ALSO applied to sudo members only
X11Forwarding
AllowTcpForwarding no
Run Code Online (Sandbox Code Playgroud)
尽管大多数配置使用缩进来提高可读性,Match
但缩进结束时a不会结束。
如果匹配行上的所有条件都满足,则以下行中的关键字将覆盖配置文件全局部分中设置的关键字,直到另一匹配行或文件末尾
Match
如果这些选项之一在该上下文中无效,则OpenSSH 只会注意到因不适当插入而导致的意外配置更改。否则,遵循说明只会变得依赖于该Match
条件。
意外的配置可以通过Match
在配置文件的最后严格插入所有块来解决- 并将所有无条件配置严格放置在第一Match
行之上。