The code is as follows |
Copy Code |
Now there are two servers, server A is accessible via extranet, server B (linux/mac/windows) is connected to A via LAN, and for a variety of reasons (firewall, extranet restrictions), we (client) cannot directly log in to B or access the business system on B. |
The code is as follows |
Copy Code |
So the question is, how do you access B through A? |
SSH is a good tool, we can through SSH's local port mapping function, the remote B port map to the local port, to achieve through A indirect access to B.
Specific commands:
具体命令:
ssh USER@HOST_A -P HOST_A_SSH_PORT -L 127.0.0.1:LOCAL_PORT:HOST_B:HOST_B_PORT
#USER A 服务器 ssh用户名,如:root
#HOST_A 服务器A IP地址(域),如:1.2.3.4
#HOST_A_SSH_PORT 服务器A ssh端口,如:22
#LOCAL_PORT 映射到本地的端口,如:13306
#HOST_B 服务器B IP地址,和A同一内网的内网IP地址,如10.0.0.102)
#HOST_B_PORT 服务器B上需要被外网访问到的端口,如3306
EG.
ssh root@1.2.3.4 -P 22 -L 127.0.0.1:13389:10.0.0.102:3389
#通过 1.2.3.4 的 ssh 用户 root,将 10.0.0.102服务器的 3389 端口映射到本地的13389端口,从来实现,通过127.0.0.1:13389连接远程win server
ssh root@1.2.3.4 -P 22 -L 127.0.0.1:13306:10.0.0.102:3306
#映射远程 MySQL端口至本地 端口 13306
Tools:
1, under Windows Putty
Save this window always open, use finished exit exit off.
2, Linux, Mac Direct Input command can, of course, can also use other tools, such as VSSH, ZOC, etc.