我希望能够在我的linux服务器上提供ssh帐户,以便人们可以使用SSH隧道。 所有帐户都将被locking在没有交互式shell的情况下,仅用于隧道/端口转发。 我的问题是,我不希望他们只能通过端口转发来访问绑定到本地主机的服务,如下所示:
ssh account@server -L 9999:127.0.0.1:3306 & telnet localhost 9999
将访问默认的mysql数据库端口..我怎样才能阻止这个?
我在OpenSSH的configuration文件中看到允许特定端口/主机的选项,但是不能阻塞它们。 任何帮助将不胜感激 :)
听起来像你想要openopen,logging在sshd(8):
permitopen="host:port" Limit local ``ssh -L'' port forwarding such that it may only connect to the specified host and port. IPv6 addresses can be specified by enclosing the address in square brackets. Multiple permitopen options may be applied separated by commas. No pattern matching is performed on the specified hostnames, they must be literal domains or addresses.
我会尝试使用iptables,像这样的东西应该解决: iptables -A INPUT -d 127.0.0.1 -j DROP如果你想让你的防火墙configuration持久保持对重新启动,你也应该制作一个脚本。