Simple implementation of remote access to Linux SVN service

Article directory

  • foreword
  • 1. Install SVN service on Ubuntu
  • 2. Modify the configuration file
    • 2.1 Modify the svnserve.conf file
    • 2.2 Modify the passwd file
    • 2.3 Modify the authz file
  • 3. Start the svn service
  • 4. Intranet penetration
    • 4.1 Install cpolar intranet penetration
    • 4.2 Create a tunnel to map a 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

Reproduced from the article of cpolar intranet penetration: Linux builds SVN server, and intranet penetration realizes remote access to public network

Foreword

With more and more documentation, keeping everything on your own computer is confusing and not easy to share. 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 the local area network, remote access to the database or code will be restricted. In order to access the internal network SVN database from the public network, cpolar can solve this demand very well. A tool for exposing services to the public network for access.

SVN is divided into server and client. The server is mainly for data storage, and the client is mainly a graphical tool to connect to the server to obtain server data. The following introduces the installation of the server in the ubuntu system and remote access 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 version library and execute the following series of commands

cd /opt
sudo mkdir svn
cd svn
sudo mkdir repository

After creation, enter the following command to create the warehouse

sudo svnadmin create /opt/svn/repository

20230131111703

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

  • The conf folder is the configuration file stored, including the permissions and passwords of the SVN user name;
  • 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 to 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 the 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 i key to enter editing
Untie the # comment of the four parameters

202301311117063

Then press Esc 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 enter the editor:

sudo vim passwd

Press i to edit

Add the following information, the account password can be defined by yourself!

20230131111707

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

2.3 Modify the authz file

This file is mainly for the authority management of the login user, enter the following command to enter the editor:

sudo vim authz

Press i to edit
Add the following information

20230131111708

Then Esc 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 it can only be accessed under the local area network at present. If you leave the local area network, 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 local area network, without the need for a public network IP or setting up a router.

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

4.1 Install cpolar intranet penetration

  • Support 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 background of the cpolar official website, click the verification on the left to view your own authentication token, and then paste the token in the command line:

cpolar authtoken xxxxxxx

20230206171248

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

4.2 Create a tunnel mapping local port

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

After successful login, click Tunnel Management on the left dashboard – Create Tunnel, create a tcp protocol tunnel pointing to the local port 3690:

  • Tunnel name: 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 on the 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

Download the svn client from the official website: https://tortoisesvn.net/downloads.html

20230131111711

After SVN is installed, right click on the desktop, click svn checkout, enter the cpolar public network address we copied, and click ok

20230131111712

Enter the account password we created earlier

20230131111713

Then right click, svn update appears at this time, click, if there is no error, the connection is successful

20230131111714

6. Configure a fixed public network TCP port address

Since the above tunnel created by using cpolar 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 a better connection, we can configure a second-level subdomain name for it, which is a fixed address and will not change randomly

It should be noted that to configure a fixed TCP port address, cpolar needs to be upgraded to a professional 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: Remarks, which can be customized

Click Save

20230131111715

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

20230131111716

6.2 Configure 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 the tunnel management on the left dashboard – tunnel list, 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, change it to a fixed tcp address, click OK after modifying

20230131111721

Then right-click svn update, click, if there is no error, the connection is successful

20230131111722