Indirect access to remote intranet servers via SSH port mapping

Source: Internet
Author: User
Tags ssh ssh port
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.