1、SSHD的配置文件/etc/ssh/sshd_config中需要的配置项(前者必须有,后者建议有,否则无法接入外部的IP地址)
AllowTcpForwarding yes
GatewayPorts yes
2、打开系统端口转发能力(修改/etc/sysctl.conf ,执行sysctl -p生效,sysctl -a查看)
net.ipv4.ip_forward = 1
3、特别注意在一些SSH客户端可能会设置过滤器(例如我使用的SecureCRT的配置文件中就有)
S:"Port Forward Filter"=allow,0.0.0.0/0.0.0.0,0
S:"Reverse Forward Filter"=allow,0.0.0.0/0.0.0.0,0
4、特别的在定位第3个问题的时候,查看SSHD在服务器上的日志/var/log/secure有下面的无法阅读的包含了8进制字符的错误日志
Jan 11 08:03:59 iZbp1c1ypacjshvgfa9j2aZ sshd[17631]: channel 3: open failed: administratively prohibited: \346\213\222\347\273\235\344\273\216 100.120.34.86:28884 \345\210\260 127.0.0.1:80 \347\232\204\350\277\234\347\250\213\350\275\254\345\217\221\350\257\267\346\261\202\357\274\214 \345\233\240\344\270\272\345\275\223\345\211\215\350\277\207\346\273\244\345\231\25