SSH能直接建立一个本地到内网的隧道嘛?
远程端口转发主要用于让外部人员访问内部服务。
本地端口转发:
Port Forwarding – Support Portal (termius.com)
SSH port forwarding can be used to gain or provide access to services that are not directly reachable, to encrypt connections between different applications and more.
Termius supports all types of port forwarding: local, remote and dynamic.
Local port forwarding
Local port forwarding is most commonly used for connecting to services on a private network, such as a database or VNC server.
This type of port forwarding redirects connections made to a port on your device (e.g. by a browser) running Termius to a device running an SSH server and then to any reachable port / device.
有三台设备
解决的问题:
1、在local通过A服务器(安装了SSH),访问B服务器
ssh -L 127.0.0.1:3336(local):10.1.30.42:3306(A服务器) daniel@daniel.local(B服务器)
Remote port forwarding
在命令行上运行下边的指令:
ssh -R 【目标服务器的IP】:8899:【远程服务器的IP】:22 【目标服务器的用户名XXXX】@【目标服务器的IP】
PS: 目标服务器就是本地的服务器;
远程的服务器就是内网的服务器;
简单理解:
==把左右手连接起来。左手是一台服务器。右手是一台服务器。两者之间不能直接通讯,但是都能访问中间的服务器。==