由于您不允许以粗体显示,我假设您希望在SSH客户端进行某种运行时拒绝,以防止端口绑定.所以,我已经为您挖掘了源代码:
serverloop.c:
/* check permissions */
if (!options.allow_tcp_forwarding ||
no_port_forwarding_flag ||
(!want_reply && listen_port == 0)
#ifndef NO_IPPORT_RESERVED_CONCEPT
|| (listen_port != 0 && listen_port < IPPORT_RESERVED &&
pw->pw_uid != 0)
#endif
) {
success = 0;
packet_send_debug("Server has disabled port forwarding.");
} else {
/* Start listening on the port */
success = channel_setup_remote_fwd_listener(
listen_address,listen_port,&allocated_listen_port,options.gateway_ports);
}
不幸的是,正如您所看到的,除了标准端口之外,没有多少条件可以阻止端口转发.
我打算在iptables中推荐使用mod_owner的相同建议,但杰夫已经打败了我.
您最干净的解决方案就是修改此文件(例如,您可以使用pw-> pw_uid来获取用户连接的uid,并将其映射到正确的端口)并重新编译SSH服务器,但这取决于如何你很舒服.