Realize remote access to the public network: quickly build an SFTP file server locally on Windows and configure port mapping

1. Set up SFTP server

1.1 Download freesshd server software

Download address: http://www.freesshd.com/?ctt=download

20221117180912

Select freeFTPD.exe to download

After downloading, click Install

20221117180919

After installation, it will prompt whether to start the background service, Yes

After installation, click Start Menu –> freeFTPd. Note : You need to right-click here 以管理员权限to open freeFTPd. If you open freeFTPd as a normal user, you will not be able to save the configuration .

20221117180926

The main picture is as follows. We see that the SFTP status is not started.

20221117180931

1.3 Start SFTP service

Select SFTP, as shown below, we see that the current SFTP status is Stopping, we click startthe button.

20221117180936

The status will change to Running..., as shown below.

20221117180941

1.4 Add user

Select the Users option window and click the Add button to add a user.

20221117180947

Add a test user aaa here. The authentication method can choose WINDOWS verification and password verification. In this example, independent password verification is selected.

User directory, we create a separate SFTP root directory for the user.

After creating, click Applythe button to save.

And don’t forget to configure the directory permissions of the SFTP root directory folder.

20221117180952

1.5 Save all configurations

Click Apply & Savethe button below. Save all configurations and write configuration files.

20221117180958

Note: If a configuration cannot be written error window pops up, it means that you have started freeFTPd as a normal user before and cannot save the configuration file. FreeFTPd needs to be reopened with administrator rights to write the configuration file normally. Perform step 1 again and save again.

20221117181005

The saved result is as shown below.

20221117181012

2 Install SFTP client FileZilla for testing

Download address: https://www.filezilla.cn/

After installation, open it, as shown below

20221117181019

2.1 Configure a local SFTP site

Click on the software toolbar 打开站点管理器, as shown below.

20221117181025

Click 新站点the button.

20221117181031

Let's create a new site with whatever name we want.

  • Select protocol: SFTP
  • Server IP: Because it is on the server, choose 127.0.0.1
  • Port number: select 22
  • Username: When setting up the sftp server for us, create a user, in this case aaa
  • Password: Enter the password of user aaa

After configuring, click 连接the button.

20221117181038

When prompted whether to save the password, click OK.

20221117181044

When connecting for the first time, you will be prompted whether to trust this host, check the box, and confirm.

20221117181050

2.2 Intranet connection test successful

We can see that the directory list on the server side has been obtained, indicating that the connection is successful.

20221117181056

3 Use cpolar intranet penetration

The prerequisite is that you have installed cpolar. If not, please refer to Installing cpolar intranet penetration tool first.

cpolar official website: https://www.cpolar.com/

Visit cpolar’s ​​official website on your browser, register an account for free, and then download and install the Windows version of cpolar’s ​​intranet penetration tool.

20230508152653

After the successful installation of cpolar intranet penetration, we open the browser to access the cpolar web UI management interface: 127.0.0.1:9200, and log in using the cpolar email account.

20221117181103

3.1 Create SFTP tunnel

隧道管理Select – from the left menu bar 创建隧道to add a new TCP tunnel.

  • Tunnel name: tunnel-sftp (you can customize it, just don’t repeat it)
  • Protocol: TCP
  • Local address: 22
  • Region: In this example, China Top is selected

Click 创建the button.

20221117181117

The tunnel list shows the tunnel we just created.

20221117181122

3.2 View the online tunnel list

In this example, the public network address we obtained is 3.tcp.cpolar.top:12284, where 3.tcp.cpolar.topis the public network address and 12284is the port number

20221117181128

4. Use SFTP client to connect to the public network address for testing

4.1 Add new site

We open filezilla and follow step 2 to add a new site.
In the toolbar, open the site manager and add a new site.

This time we named the sitecpoalr sftp

  • Protocol: SFTP
  • Host: 3.tcp.cpolar.top (This example may be different from yours, refer to the online tunnel list)
  • Port: 12284 (This example may be different from yours, please refer to your online tunnel list)

20221117181134

4.2 Successfully connected to the sftp server through the public network

You can see that the SFTP server has been successfully connected through the public domain name provided by cpolar.

20221117181140


PS: If there is a problem with Chinese directory garbled characters, it can be solved by configuring the character set in the SFTP client:

  • Set character set toGBK
  • [Since most of the current Linux character sets have been changed to UTF-8 for universal use, and the default character set of Windows is GBK, you only need to set the character set to GBK, and there will be no garbled characters]

20221117181149

20221117181156

Summarize:

In this example, we built an SFTP site in Windows, and after the local network test was successful, we used the cpolar penetration tool to make the SFTP site available on the public network. Since the free package is used in this example, the public address and port of the sftp site will change within 24 hours, which will be very inconvenient for frequent use. It is recommended to upgrade to the professional package or above and configure it as a fixed TCP tunnel for a better experience. Note that the professional package has 3 times the bandwidth of the free package. [cpolar currently supports a 21-day money back guarantee]

Guess you like

Origin blog.csdn.net/m0_67768006/article/details/132610026
Recommended