Remote connection to Linux via external SSH

Connect to my development board remotely through an external network. Internal network penetration technology is required here.
In Linux systems, there are multiple ways to achieve intranet penetration. Here, a intranet penetration software called cpolar is used, which does not restrict traffic and can be used permanently for free. After completing the software configuration, the SSH tunnel will be installed by default. Simply start it to obtain the SSH tunnel and map the public network address of port 22.

1. Installation cpolar

mkdir cpolar
cd cpolar/
wget https://www.cpolar.com/static/downloads/install-release-cpolar.sh

Check the cpolar version information. If it displays normally, the installation is successful

root@ArmSom-sige7:/userdata/work/cpolar# cpolar version
cpolar version 3.3.12

Note:

  • The default installation path for cpolar is/usr/local/bin/cpolar.
  • The installation script will automatically configure the system service script, and after startup, it can start up automatically.
  • If installed for the first time, a simple sample configuration file will be configured by default. Two sample tunnels have been created, one web and one ssh.
  • Cpolar configuration file path:/usr/local/etc/polar/cpolar. yml.

2.Register a cpolar account

cpolar official website address: cpolar官网-安全的内网穿透工具 | 无需公网ip | 远程访问 | 搭建网站
Follow the prompts to register a free account.
Afterwards, you will receive a token

3.Run cpolar

Configure the Authtoken obtained in the first step

cpolar authtoken YzkyYjY4YzYtZmUyNy00Yj

Authtoken must be specified for cpolar, which will save your Authtoken in ~/. cpolar/cpolar. yml

Configure systemctl service

root@ArmSom-sige7:/userdata/work/cpolar# systemctl enable cpolar
root@ArmSom-sige7:/userdata/work/cpolar# systemctl start cpolar
root@ArmSom-sige7:/userdata/work/cpolar# systemctl status cpolar
● cpolar.service - Cpolar Service
     Loaded: loaded (/etc/systemd/system/cpolar.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-01-03 08:32:50 UTC; 29min ago
       Docs: https://www.cpolar.com/docs
   Main PID: 23086 (cpolar)
      Tasks: 28 (limit: 9339)
     Memory: 16.8M
        CPU: 9.262s
     CGroup: /system.slice/cpolar.service
             ├─23086 cpolar: master process
             └─23097 cpolar: worker process
root@ArmSom-sige7:/userdata/work/cpolar#

4.Obtain the address of the SSH tunnel

Accessing in PC machine browser: http://192.168.100.103:9200 , log in to the cpolar web UI management interface; Among them, 192.168.100.103 is the internal IP address of my development board.

5.Public SSH remote Linux service

By executing commands on external network devices, you can ssh remote Linux services on the internal network:

ssh ${Linux username} @ ${Public address generated by cpolar} - p ${Port number generated by cpolar}

For example, the command I used for testing is as follows:

ssh armsom@2.tcp.vip.cpolar.cn -p  14649