Build SVN server in Linux environment and achieve public network access – cpolar port mapping

Article directory

  • Preface
  • 1. Install SVN service on Ubuntu
  • 2. Modify configuration file
    • 2.1 Modify the svnserve.conf file
    • 2.2 Modify passwd file
    • 2.3 Modify authz file
  • 3. Start the svn service
  • 4. Intranet penetration
    • 4.1 Install cpolar intranet penetration
    • 4.2 Create tunnel mapping local port
  • 5. Test public network access
  • 6. Configure a fixed public network TCP port address
    • 6.1 Reserve a fixed public network TCP port address
    • 6.2 Configure a fixed public network TCP port address
  • 7. Use fixed TCP port address for remote SVN service

Foreword

As there are more and more documents, storing all the information on your own computer can be confusing and not conducive to sharing. In this case, consider uploading the data to SVN for unified management, so that other people can easily check various data.

When SVN is installed in a local area network, remote access to the database or code will be restricted. In order to access the intranet SVN database from the public network, [cpolar] (blog – cpolar Jiidian Cloud) can solve this problem very well. Requirements: cpolar is a tool that can expose intranet services to the public network for access.

SVN is divided into server and client. The server is mainly used for data storage. The client is mainly a graphical tool to connect to the server to obtain server data. The following describes how to install the server on the Ubuntu system and access it remotely through the client.

1. Install SVN service on Ubuntu

Enter the installation command on the command line:

sudo apt install subversion

20230131111701

Check the svn version. If the version information appears, the installation is successful:

svnserve --version

20230131111702

Create a repository and execute the following series of commands

cd /opt
sudo mkdir svn
cdsvn
sudo mkdir repository

After creation, enter the following command to create the warehouse

sudo svnadmin create /opt/svn/repository

20230131111703

After successful creation, we will find a series of files in the repository directory, including:

  • The conf folder contains configuration files, including SVN username permissions and passwords;
  • The db contains different versions of the documents, codes and other data we uploaded to the SVN server.

What needs to be noted here is to release permissions on the db folder, otherwise the client may not be able to connect to the SVN server.

20230131111704

Enter the following command to release permissions on the db folder. After the release is successful, the db folder will turn green.

sudo chmod -R 777 db

20230131111705

2. Modify configuration file

First modify the files in the conf folder under the repository file

2.1 Modify the svnserve.conf file

This file mainly sets our SVN access method. Enter the editing command:

sudo vim svnserve.conf

Press the i key to enter editing
Unlock the # comments of the four parameters

202301311117063

Then press the Esc key to exit editing, enter :wq to save and exit.

2.2 Modify passwd file

This file is mainly to add the user name and password, enter the command to edit:

sudo vim passwd

Press i to edit

Add the following information, the account password can be customized!

20230131111707

After adding, press Esc key to exit, enter :wq to save and exit.

2.3 Modify authz file

This file is mainly for permission management of logged-in users. Enter the following command to edit:

sudo vim authz

Press i to edit
Add the following information

20230131111708

Then Esc key to exit editing, enter :wq to save and exit.

3. Start svn service

Enter the following command to start svn

sudo svnserve -d -r /opt/svn/

4. Intranet penetration

Above we installed the svn server on the local Ubuntu virtual machine, but currently it can only be accessed under the LAN. If you leave the LAN, you will not be able to connect to svn. However, we can use cpolar to achieve public network access, breaking through the limitations of the LAN, without requiring a public network IP or setting up a router.

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

4.1 Install cpolar intranet penetration

  • Supports one-click script installation command
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • token authentication

Log in to the cpolar official website backend, click Verify on the left to view your authentication token, and then paste the token into the command line:

cpolar authtoken xxxxxxx

20230206171248

  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar

4.2 Create tunnel mapping local port

After successfully starting the cpolar service, we access the local 9200 port [http://127.0.0.1:9200] on the browser and log in to the cpolar web UI management interface.

After successfully logging in, click Tunnel Management – Create Tunnel on the left dashboard to create a TCP protocol tunnel pointing to the local port 3690:

  • Tunnel name: It can be customized. Be careful not to duplicate the existing tunnel name.
  • Protocol: tcp
  • Local address: 3690
  • Domain name type: Choose a random domain name for free
  • Region: Select China VIP

Click Create

20230131111709

After the tunnel is successfully created, click Status on the left – Online Tunnel List. You can see that the tunnel just created has generated a corresponding public network address. Copy it.

20230131111710

5. Test public network access

Official website to download the svn client: https://tortoisesvn.net/downloads.html

20230131111711

After SVN is installed, right-click on the desktop, click svncheckout, enter the cpolar public network address we copied, and then click ok

20230131111712

Enter the account password we created earlier

20230131111713

Then right click, then svn update will appear, click it, if no error appears, the connection is successful.

20230131111714

6. Configure a fixed public network TCP port address

Since the tunnel created using cpolar above uses a random public network address, this address is a random temporary address and will change within 24 hours, which is not conducive to long-term remote access.

For better connection, we can configure a second-level subdomain name for it. This address is a fixed address and will not change randomly.

It should be noted that configuring a fixed TCP port address requires upgrading cpolar to the Professional Edition package or above. [cpolar supports 21-day money back guarantee]

6.1 Reserve a fixed public network TCP port address

Log in to the cpolar official website, click Reserve on the left, and select the reserved TCP address. Let’s first reserve a fixed port address for the remote SVN.

  • Region: Select China VIP
  • Description: Notes, which can be customized

Click Keep

20230131111715

After the address is successfully reserved, the system will generate the corresponding fixed public address and copy it.

20230131111716

6.2 Configure a fixed public network TCP port address

Access port 9200 on the browser, http://127.0.0.1:9200/, log in to the cpolar web ui management interface, click Tunnel Management – Tunnel List on the left dashboard, find the svn tunnel, and click Edit on the right

20230131111717

Modify the tunnel information and configure the successfully reserved fixed tcp address into the tunnel.

  • Port type: modified to fixed tcp port
  • Reserved tcp address: fill in the successfully reserved address

Click Update

20230131111718

After the tunnel is successfully updated, click the status on the left dashboard – Online Tunnel List, find the Minecraft Tunnel, and you can see that the public network address has been updated to a fixed TCP address.

20230131111719

7. Use fixed TCP port address for remote SVN service

Right click to open relocate

20230131111720

Modify the connection address to a fixed tcp address. Click OK after modification.

20230131111721

Then right-click svn update and click. If no error occurs, the connection is successful.

20230131111722

Reprinted from cpolar pole cloud article: Linux builds SVN server and penetrates the intranet to achieve remote access to the public network