SecureCRT远程端口转发不生效的解决方法

简介: SecureCRT远程端口转发不生效的解决方法

640.jpg

SecureCRT远程端口转发


在上一篇文章【利用腾讯云主机+SSH远程端口转发实现内网穿透】中使用SecureCRT进行远程端口转发,但是转发到云主机(外网)服务器后,发现从外网访问连接转发后的端口出现报错,无法正常访问


通过Google搜索相关问题,最终找到了问题的根因

640.png

如下图所示


640.png


  1. 内网Win10 192.168.198.1
  2. 内网CentOS7.6服务器 192.168.198.130 SSH端口22
  3. 云主机CentOS7.6一台 公网IP X.X.X.X

需求场景:通过内网win10机器SecureCRT连接上云主机的SSH,配置SecureCRT远程端口转发,将本地192.168.198.130 SSH端口22转发到云主机的8622端口上

  1. 云主机SSH配置中已经将/etc/ssh/sshd_config中GatewayPorts no改为了GatewayPorts yes
  2. 云主机安全组中也将TCP 8622端口放通


具体排查与解决步骤如下


1、问题复现

640.jpg


640.jpg

640.jpg

640.jpg

2、开启SecureCRT Trace Option

可发现如下报错提示


[LOCAL] : RECV: CHANNEL_OPEN[forwarded-tcpip] 
[LOCAL] : Rejecting remote forward request from 61.X.X.X:54962 to 192.168.198.130:22 because the current filters do not allow 61.X.X.X:54962 to use the remote forward.

640.jpg

640.jpg

3、修改会话ini文件中Reverse Forward Filter


修改前为


S:"Reverse Forward Filter"=allow,127.0.0.1,0 deny,0.0.0.0/0.0.0.0,0

640.jpg

修改后为


S:"Reverse Forward Filter"=allow,0.0.0.0/0.0.0.0,0

640.jpg


也就是允许所有IP访问


4、修改完成后重新打开SecureCRT,并打开该SSH会话


这时就可以正常从外网访问连接转发后的端口,问题解决


640.jpg



下面是SecureCRT官网论坛关于Remote port forwarding filter/Reverse Forward Filter的说明


SecureCRT's port forwarding "allowances" fall on the cautious side of security. This is the case for both local and remote/reverse port fowards, which ensures security by default but also means it's not the most convenient default setting if your needs are "special".
In the case of reverse forwards, SecureCRT imposes a default filter that rejects any forwards that don't originate on the server side from the server's loopback address (127.0.0.1). This means that if the (server-side) client application sets the src addr to anything other than 127.0.0.1 (such as a non-loopback NIC address like 192.168.x.y), SecureCRT will deny such forwarding packets received, dropping packets w/o forwarding them on to the configured destination on the SecureCRT side. Such a denial can be seen in debug output if you enable Trace Options (SecureCRT's main "File" menu) prior to connecting to the remote machine.
A denial/rejection looks like this, as one example, in Trace Options debug output (displayed in the SecureCRT terminal window the moment a server-side client application attempts to access the port from a filtered src address/port):
[LOCAL] : RECV: CHANNEL_OPEN[forwarded-tcpip]
[LOCAL] : Rejecting remote forward request from 192.168.232.101:1220 to 10.0.0.1:8080 because the current filters do not allow 192.168.232.101:1220 to use the remote forward.
To relax SecureCRT's reverse forward filters to allow access for more than just localhost-originating addresses on the remote side, you'll need to manually edit the session's .ini file appropriately (make sure you close SecureCRT prior to changing a session's .ini file manually).
Here's the line in the session's .ini file that you'll need to modify:
S:"Reverse Forward Filter"=allow,127.0.0.1,0 deny,0.0.0.0/0.0.0.0,0
If you want to allow everything through (not the most secure choice, but works if you're just setting it up for a PC on a controlled LAB network), do this:
S:"Reverse Forward Filter"=allow,0.0.0.0/0.0.0.0,0
If you just want to allow everthing on the 192.168.x LAN segment, as well as any loopback adapter access to the forwarded port (denying access to all other originating addresses), do this:
S:"Reverse Forward Filter"=allow,192.168.0.1/255.255.0.0,0 allow,127.0.0.1/255.0.0.0,0 deny,0.0.0.0/0.0.0.0,0
This information is described in detail (including ipv6 how-to) within the SecureCRT help under the topic titled, "Configuring Port-Forwarding Filters" located within the "Secure Connections" top-level chapter.


640.jpg

640.jpg

附上SecureCRT本地端口转发与X11转发的原理图,未收集到远程端口转发的原理图

640.png

640.png

相关文章
|
4月前
|
Linux Windows
端口占用的解决方法
本文介绍了在Windows和Linux系统中解决端口占用问题的方法,包括使用`netstat`命令查看端口占用情况、`tasklist`命令查找对应进程,以及使用`taskkill`命令终止进程,在Linux系统中则使用`netstat`或`lsof`命令查找占用端口的进程,并用`kill`命令结束进程。
|
5月前
|
Prometheus 监控 Kubernetes
将service类型由"ClusterIP"改为"NodePort"无法使用nodeip+端口访问服务解决方法.
将service类型由"ClusterIP"改为"NodePort"无法使用nodeip+端口访问服务解决方法.
|
7月前
|
安全 网络安全 数据安全/隐私保护
阿里云服务器不能发邮件禁用25端口的三种解决方法
阿里云服务器不能发邮件禁用25端口的三种解决方法
891 0
|
SQL Windows
Windows 下80端口被进程 System & PID=4 占用的解决方法
Windows 下80端口被进程 System & PID=4 占用的解决方法
854 0
|
负载均衡 应用服务中间件 Linux
只能使用UDP:514端口接收Syslog日志的两种解决方法
只能使用UDP:514端口接收Syslog日志的两种解决方法
3227 0
只能使用UDP:514端口接收Syslog日志的两种解决方法
|
算法
交换机:广播风暴产生原因与解决方法、STP生成树协议 ,根桥(根交换机)、备份根桥、非根交换机、根端口、指定端口、非根非指定端口、桥ID
广播风暴产生原因和危害、STP生成树协议 概念和作用、STP生成树根桥选举规则,根桥、备份根桥、非根交换机、根端口、指定端口、非根非指定端口、桥ID的选择条件,根换交换机接口Cost计算标准命令,华为设备默认的标准是IEEE 802.1t标准,思科设备默认的标准是IEEE 802.1d标准(标准可用命令更换),查看交换机的BID的命令........................
交换机:广播风暴产生原因与解决方法、STP生成树协议 ,根桥(根交换机)、备份根桥、非根交换机、根端口、指定端口、非根非指定端口、桥ID
|
Java 应用服务中间件 程序员
Tomcat 最新版安装与使用手册,tomcat更改端口号方法,tomcat控制台乱码问题解决方法
Tomcat 最新版安装与使用手册,tomcat更改端口号方法,tomcat控制台乱码问题解决方法
168 0
Tomcat 最新版安装与使用手册,tomcat更改端口号方法,tomcat控制台乱码问题解决方法
|
网络安全 Docker 容器
docker 端口映射错误解决方法
docker 端口映射错误解决方法
541 0
|
Android开发
android adb 进程端口号被占解决方法
1、查看adb 的进程端口号是什么,输入命令 adb nodaemon server 显示端口号 2、查看端口号对应的进程pid ,输入命令 netstat -ano  查看对应的端口号的进程号 3、查看进程号对应...
2083 0

热门文章

最新文章